Generalization of destructuring assignment, has this been discussed before?
Lasse Reichstein
reichsteinatwork at gmail.com
Wed Sep 21 00:17:20 PDT 2011
Destructuring allows, e.g.,
var o = {};
[o.x, o.y] = [1, 2];
I.e., a generic LValue as a Field.
Could this be generalized to working outside of array/object braces in
declarations, e.g.:
var o.x = 42; // Declared non-configurable
const o.x = 37; // Declared non-Wrtiable and non-configurable
and the *real* reason for suggesting it, a highly convenient shorthand:
function Foo.prototype.bar() { ... }
I think I have seen this suggested before, but it might just be Crockford's
web pages at some point (perhaps the one suggesting "::" as abbreviation for
".prototype."). Has it been suggested for ES?
There doesn't seem to be any syntactic ambiguity (but it can foil look-ahead
on functions if function
calls are allowed as LValues, since "function foo()()()()()()()() { ... } "
won't know which parenthesis
starts the arguments until it sees the end of them).
Ofcourse, "classes" might remove the usecase for "in place function
declaration" above.
/L
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110921/1ce9148f/attachment.html>
More information about the es-discuss
mailing list