Constructing objects from named identifiers

Bob Myers rtm at
Thu Jun 2 19:06:42 UTC 2016

The proposal of mine referenced by John in his link is obsolete, and has
been replaced by, with a new
minimal variation at which
precisely leverages the current syntax and semantics of deconstructing.

John's proposal for picking into an anonymous object:

({p1, p2}) = o

overloads parentheses in a strange way, and is too easily confused with

({p1, p2} = o)

which means a completely different thing, and furthermore violates the
semantics of the assignment operator, which is that it evaluates to the
RHS, whereas he presumably intended this to evaluate to the newly created

The assignment operator `=` makes sense in current deconstructing
assignments, since it *is* an assignment. It makes no sense in the context
of picking properties into objects.

In my proposal, this is

o.{p1, p2}

which has a clear analogy to the "single property picking" syntax `o.p1`,
is syntactically unambiguous, easily parsable using existing machinery for
parsing deconstructors, and by virtue of re-using current deconstruction
syntax allows for renaming and defaults out of the box.

I've approached a couple of possible champions for this but no dice so far.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list