[Cosmo-dev] Re: [commits-cosmo] (br) [4567] this is a better way not to clobber namespaces.

Jeremy Epstein eggfree at eggfree.net
Thu Jun 7 16:22:21 PDT 2007


Matthew and co.

by the way, this may seem like an awful aside, but where did the use of 
"self" as a proxy for "this" come in?
I say this because nominally in javascript "self" is a reserved word 
that refers to the current window when used in event handlers. I'm not 
disputing why you might want to use a variable like that, only the 
choice of name.

Jeremy



Nicola Piccinini wrote:
> Hi,
>
> thanks for your kind reply.
> Unfortunately my message was vague and I need to make it more precise.
>
>> Actually, in the 0.6.1, the references to 'Cal' you see in the code 
>> point to cosmo.ui.cal_main.Cal. You can see the alias at the bottom 
>> of cosmo/ui/cal_main.js.
>
> yes but I meant really cosmo.view.cal (sorry for confusing ideas 
> calling it "cal" singleton).
> In Cosmo 0.6.1 we have the following hierarchy:
> cosmo.view.cal
> cosmo.view.cal.Lozenge
> cosmo.view.cal.canvas
> cosmo.view.cal.conflict
> cosmo.view.cal.dialog
>
> So cosmo.view.cal is a namespace.
> Moreover cosmo.view.cal is also a singleton, in fact in cal.js we have:
> cosmo.view.cal = new function () {
> ...
> }
>
> That means that Lozenge, canvas, etc. are properties of this singleton 
> and if the singleton is inadvertely reinitialized, this properties are 
> lost. This in fact caused me some troubles and I had to "mixed in" the 
> cosmo.view.cal object with cosmo.view.cal namespace to solve them.
>
> As far as I can understand, in cosmo 0.7 things aren't much different 
> in fact in [4567] you are mixing in the "new function()" with the 
> namespace. The situation is even more awkward because of the scoping 
> questions explained by Travis.
>
> So my point is: why not to avoid some of these potential problems 
> separating cosmo.view.cal namespace from cosmo.view.cal object (which 
> could become cosmo.view.cal.Cal)? What are the advantages in 
> maintaining the current double nature of cosmo.view.cal?
>
> Many thanks,
> Nicola
>
>
> _______________________________________________
> cosmo-dev mailing list
> cosmo-dev at lists.osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/cosmo-dev
>
>


More information about the cosmo-dev mailing list