If I correctly understood, A is for the supposedly existing case where someone
would add a property to an object before you “extend.{}” it to alter the way
that property is handled, in order to get acces to things you wouldn’t have
thought they could gain access to but that you’re putting on a public field of
an object you’re not sure to trust.
This is a very contreived use case, considering that if you can’t trust the
object you’re working with, it can very possibly be a proxy, in which case even
[[DefineOwnProperty]] can lead to unintended leaks.
From: T.J. Crowder
Sent: Wednesday, May 30, 2012 11:17 AM
To: Brendan Eich ; [email protected]
Subject: Re: New Object Extension Literal Strawman
On 30 May 2012 05:09, Brendan Eich <[email protected]> wrote:
Brendan Eich wrote:
The only usable+secure extensions I see are two, so we don't confuse users
with almost-identical syntax with quite different (when it matters most, when
under attack) semantics:
A. obj.{prop: val, ...} as safe mustache, with : for define not assign.
B. obj.[prop = val; ...] with meta... of course, for fluent-style chained
assignments of obj's props.
I use [ not { for the chained case so the bracketing as well as
;-separation (final ; is optional) and = not : distinguish B from A for readers
looking at any punctuation.
Stop me if you've heard this one before...
For B, instead of [] we could use () as the chained set/call brackets. E4X
(ECMA-357) defines xml.(expr) as a filtering predicate expression, but no
worries, E4X is going away.
So A remains
obj.{x: val, y: val};
...where these are [[DefineOwnProperty]]
and B becomes
obj.(x = val; y = val);
...where these are [[Put]]
Is the idea to _only_ have B, or to have both A and B? I see clear use cases
for B. I'm not immediately seeing them for A but I came late-ish to the
discussion.
-- T.J.
--------------------------------------------------------------------------------
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss