Lexically Scoped Object Extensions (was About private names)

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Mar 21 18:17:44 PDT 2011


On Mar 21, 2011, at 5:55 PM, Waldemar Horwat wrote:

> You'd still run into all of the issues caused by "private filter" behaving like a C++ #define.  For example:
> 
> var foo = {filter: 34};
> then pass foo to an outside client.



Trying to interpret your comment.  Are you saying that the above appearing within the scope of the "private filter" would unintentionally use private foo instead of public foo?

That's true, but the whole point of the block  (and the extension declaration) was to constrain the visibility of private filter, so it could be used as an extension property name in a limited scope.  Defining a property using that name within that scope seem like a pretty clueless error.  Sure, it will happen, but I don't see how this use of lexically scoping is any more or less error prone an any other use.

Allen


More information about the es-discuss mailing list