Namespaces on definitions

Waldemar Horwat waldemar at google.com
Wed Apr 16 13:02:51 PDT 2008


There is an old downside to the attribute syntax:  You can't put line breaks between the attributes and the definition, even though it's tempting to do so on long lines.  Otherwise you silently change the meaning of existing ES3 code like:

foo
var bar = 3

    Waldemar


Jeff Dyer wrote:
> Here are some other interesting cases involving destructuring patterns.
> 
> Qualified syntax:
> 
>   var {x = ns::x, y = ns::y, z = ns::z}: {x:A, y:B, z:C } = ...
>    var [ns::x, ns::y, ns::z}: [A, B, C ] = ...
> 
> Attribute syntax:
> 
>    ns var {x, y, z}: {x:A, y:B, z:C} = ...
>    ns var [x, y, z]: [A, B, C] = ...
> 
> To my eye the latter are cleaner and clearer. There is another sense in 
> which I think the attribute syntax is better. The identifier is the 
> short name of the binding and having it cleanly delineated from the 
> namespace part of the name makes the meaning of the binding clearer.
> 
> I agree that having two ways of naming properties is unfortunate, but 
> it’s probably unavoidable. I tried the opposite approach of using ‘var’ 
> and ‘const’ forms in object initializers to get rid of some uses of 
> qualified names there. But in the end, that is just noisier. I’ve 
> resigned myself to the view that “N::X” is the way to name dynamic 
> properties, and “N var X” (and the like) is the way to name fixed 
> properties.
> 
> Jd
> 
> On 4/16/08 6:38 AM, Brendan Eich wrote:
> 
>     On Apr 16, 2008, at 2:50 AM, Yuh-Ruey Chen wrote:
> 
>         I agree. I don't see why there should be multiple syntaxes that
>         are as 
>         concise as each other and both have about equal precedent (AS3
>         vs. E4X). 
>         If in some futuer spec, properties can inhabit multiple
>         namespaces, then 
>         we can consider the |ns1 ns2 ... var foo| syntax again.
> 
> 
>     The syntaxes are not equally concise, not only because :: is heavier
>     visually and in terms of keyboard input (two shifted chars) than
>     spaces. Consider
> 
>       ns var foo, bar;
> 
>     vs.
> 
>       var ns::foo, ns::bar;
> 
>     It's true you can't distribute one type across several variables:
> 
>       var foo:T, bar:T;
> 
>     but that's not a reason to restrict namespace syntax /per se/.
> 
>     Cases of ns including public, protected, private, and internal may
>     be the most useful ones for this distributive syntax, but are those
>     namespaces? Either way, the ns var foo syntax is more concise.
> 
>     /be
> 
>     ------------------------------------------------------------------------
>     _______________________________________________
>     Es4-discuss mailing list
>     Es4-discuss at mozilla.org
>     https://mail.mozilla.org/listinfo/es4-discuss
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss




More information about the Es4-discuss mailing list