New private names proposal

Kris Zyp kris at
Thu Dec 16 13:40:42 PST 2010

Hash: SHA1
This sounds great, but doesn't this kind of violate referential
transparency? The following function has always worked as expected:
function foo(){
  var obj = {"bar":"hello"}; // assuming quoting names are strings
until is put in a context (or even just concatenated with?) with a
"private bar;" declaration. Changing the behavior of property
identifiers seems like an awkwardly complicating addition to EcmaScript.

Couldn't the goals of this be achieved by having a Name constructor
(albiet less convenient syntax, since you have to use obj[name],
perhaps that is what you are addressing) or having private name create
a name Name (to be used like obj[name])?

On 12/11/2010 4:58 PM, Allen Wirfs-Brock wrote:
> On the wiki, I've posted a new strawman Private Name
> proposal .
> It replaces Dave and Sam's original Names strawman and was developed
> in consultation with them. This is a significant revision to the
> original proposal but builds upon some of the same base ideas.
> In reading this strawman it's important to understand that its
> concept of "private" is quite different from what you may be use to
> from C++ or Java. In those languages "private" is an attribute of
> a member (field or method) of an class. It means that the member is
> only accessible to other members of the same class (ignoring what
> can be done via reflection). This model is not a particularly good
> match to the JavaScript object model where the structure of an
> object is much more dynamic and method functions can be dynamically
> associated or disassociated with an object and shared by many
> different kinds of objects.
> In this proposal, "private" is an attribute of a property name,
> rather than of an actual property. Any code that has access to a
> "private name" can use that name to create or access a property of
> any object. It is accessibility to the name that is controlled
> rather than accessibility to the property. This seems to fit more
> naturally with JavaScript's dynamic object construction patterns
> and without really changing the fundamental JavaScript object
> model it enables JavaScript programmers to create a number of
> different information hiding abstractions.
> Please read the proposal and let's start the discussion.
> Allen
> _______________________________________________
> es-discuss mailing list
> es-discuss at

- -- 
Kris Zyp
(503) 806-1841

Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list