On 8/8/2012 11:40 AM, Brendan Eich wrote:

To be fair, the issue is not overridng "own" read-only or setter-based
properties. It is overriding delegated properties.

But there too one can argue, and extant code wants (see WebIDL),
assignment-invoking-a-setter to abstract over prototype delegation.
That's enough for me to want non-writable assignment failure to match.
Others disagree, but I think they're doing so out of pragmatism more
than principle (the Caja/SES frozen built-in prototypes problem).

Pragmatism is fine, but for the long run I think we are better off
providing both assign and define "screwdrivers" (to use Kevin Smith's
metaphor). Then in principle everyone wins. There's still a hard case
for Caja on older browsers, but that's (a) temporary; (b) solvable at
some cost (as Mark et al. cleverly have indeed solved it).

So I think the long-run right answer, given the sunk cost non-fallacy of
Caja having to deal with most browsers in the field rejecting write
attempts that would shadow a non-writable proto-property, is to level
the field: = and :=, Object.assign and Object.define if appropriate. I'm
not sure batch assignment pays for itself, but we can check on Dart's
experience and user-test and argue that one separately.

I am not in favor of adding := to the language (as I am not in favor of adding to the language generally), but if := is added, my practical advice will be to always use := and never use =. We will probably see better performance with := since it doesn't have to slide down the proto chain to see if the assignment works. And I like stepping away from ='s visual ambiguity, looking too much like an equality operator. It could be argued that = is still needed for respecting some kinds of inherited stuff, but it could also be argued that those kinds of inherited stuff are just weird edge cases that can now be conveniently and efficiently avoided.

So if we do add :=, we should allow it to work on variables too, for consistency.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to