Private names use cases
Allen Wirfs-Brock
allen at wirfs-brock.com
Mon Dec 20 09:21:40 PST 2010
I've seen mentions in the recent thread that the goal of the "Private Names" proposal was to support "private fields" for objects. While that may be a goal of some participants in the discussion, it is not what I would state as the goal.
I have two specific use cases in mind for "private names":
1) Allow JavaScript programmers, who choose to do so, to manage the direct accessibly of object properties. This may mean limiting access to methods of a particular instance, or to methods of the same "class", or to various friends or cohorts, etc.
2) Allow third-party property extensions to built-in objects or third-party frameworks that are guaranteed to not have naming conflicts with unrelated extensions to the same objects.
Of these two use cases, the second may be the more important.
Note that I emphasized "properties" rather than a new concept such as "private fields". I believe we should be trying to build upon the conceptual foundation of the existing JavaScript object model whenever possible. We should strive to avoid introducing new concepts such as non-property fields into the object model. (see http://www.wirfs-brock.com/allen/posts/43 for further thoughts on this topic.)
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101220/c258797a/attachment.html>
More information about the es-discuss
mailing list