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

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

Reply via email to