-----BEGIN PGP SIGNED MESSAGE-----
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
  alert(obj.bar);
}
foo();
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])?
Kris


On 12/11/2010 4:58 PM, Allen Wirfs-Brock wrote:
> On the wiki, I've posted a new strawman Private Name
> proposal http://wiki.ecmascript.org/doku.php?id=strawman:private_names .
> 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@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

- -- 
Kris Zyp
SitePen
(503) 806-1841
http://sitepen.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iEYEARECAAYFAk0Kh1oACgkQ9VpNnHc4zAzCbgCcCl6kh77DCuCmd1YRw7hqC/Ml
LwcAn0V7Wm0Yr7FzGW618atYT4c7kVHO
=eoj3
-----END PGP SIGNATURE-----

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to