On Dec 22, 2010, at 11:12 AM, David Flanagan wrote:
> 've now realized that I don't actually object so much to the generative
> nature of private. What bugs me is that it essentially declares a
> meta-identifier that is then used as if it were a regular identifier. It is
> the meta-mismatch that I have a problem with.
JavaScript already has such "meta identifiers". But they can't be used as
"regular identifiers" (which I'll interpret as meaning expression contexts),
instead they only occur after a dot or on the left hand side of a colon in an
object literal. the private names proposals creates the exact same kind of
"meta identifier" for use in the exact same contexts (and adds a new #.
context). It simply extends the scoping and binding of such meta identifiers.
More explicitly in JavaScript:
var x= new Object;
var obj={x:x}; //same identifier, two different meanings
obj.obj=obj;
>
> If "private foo" declared a meta identifier <foo>, and I could then write
> o.<foo>, that would make sense to me. But of course, that syntax is more
> cumbersome than just using square brackets.
>
> It feels to me as if the private declaration is behaving like a macro.
>
> Are there precedents for this kind of meta-identifier in other languages?
For example, member names in C structs scope to the type that defines them
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss