On Fri, Jan 20, 2012 at 10:59 AM, Erik Arvidsson
<[email protected]> wrote:
> On Fri, Jan 20, 2012 at 10:46, Herby Vojčík <[email protected]> wrote:
>> No, I asked for something else. How do it do: "get a private property of
>> <<foo>> whose name is computed by <<expression>>"? Something like
>> foo.@[expr]? Or is there no way to do it?
>> In other words, what is [] syntax for foo.@bar? foo.@["bar"]? foo["@bar"]?
>
> @bar is a shorthand[*] for this[bar]
> object.@bar is a shorthand[*] for object[bar]
>
> There is no way to compute a string "bar" to do the lookup since that
> would break private name encapsulation:
>
> let object = ...
> {
>  let key = Name.create()
>  let secret = {}
>  object.@key = secret
> }
>
> There must be no way to get access to secret here.
>
> [*] Using @ does not really invoke []. That is important if private
> names are going to work with the extended collection proposals Allen
> proposed. 
> http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation

Shorter Arv: Private Names are not strings, they're unforgeable
objects.  Thus, it's impossible by design to have an analog of
foo["bar"+baz] for Private Names.  I wrote a blog post about the
subject: <http://www.xanthir.com/blog/b4FJ0>

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to