On May 30, 2012, at 2:48 PM, Herby Vojčík wrote:
> You need (need in the sense "having readable construct to perform") .{...}
> with [[DefineOwnProperty]] not for "foo":"bar" (yes, there [[Put]] should
> happen), but for dynamically adding concise methods and/or getters/setters to
> objects.
>
> Using API is much more cumbersome here. And lots of bugs can appear if people
> will use .defineProperties instead of .defineMethod, for example.
> And object literal extension, because it has identical syntax, is super
> readable.
That makes sense, as far as that goes.
> Not that I don't like the idea, by the way... but stopping literal extension
> is too much. Retain it in some way (like foo.={literal} or so).
Yeah, it's only one character, but it makes a world of difference IMO. The
importance is that -- I claim -- the ":" character in a literal does not
intuitively mean "do this imperative operation." Instead, the whole literal
reads as "this is a bunch of data, give me an object with that data in it." Put
differently, it reads as an atomic operation (even though technically it has an
operational definition).
That said, I'm still not at all convinced that the use cases of defining
getters/setters on existing objects really needs new syntax. We have syntax for
getters/setters on new objects. We (and/or devs) can define more usable API's
for adding getters/setters to existing objects. I don't see that it's a common
enough use case to be worth another syntactic addition.
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss