Constructing objects from named identifiers

Cyril Auburtin cyril.auburtin at gmail.com
Thu Jun 2 19:34:10 UTC 2016


I don't see a need at all for that, since anyway you often need other
manipulations, so if you need a functional way you can do:

`let foo = ({a,b})=>({a:a+1, b:b+2})`

then use foo on o1

or if you need to, you use destructuring declaratively:

`let {a, b} = o1` or `({a,b} = o1)` when reassigning a and b




2016-06-02 21:06 GMT+02:00 Bob Myers <rtm at gol.com>:

> The proposal of mine referenced by John in his link is obsolete, and has
> been replaced by https://github.com/rtm/js-pick-notation, with a new
> minimal variation at
> https://github.com/rtm/js-pick-notation/blob/master/minimal/spec.md which
> precisely leverages the current syntax and semantics of deconstructing.
>
> John's proposal for picking into an anonymous object:
>
> ```js
> ({p1, p2}) = o
> ```
>
> overloads parentheses in a strange way, and is too easily confused with
>
> ```js
> ({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
> object.
>
> 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
>
> ```js
> 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.
>
> --
> Bob
>
>
>
>
>
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160602/02520042/attachment.html>


More information about the es-discuss mailing list