Proposal: syntactic sugar for extracting fields from objects

Bob Myers rtm at gol.com
Thu May 30 18:23:42 UTC 2019


I don't know what "community" means, other than a bunch of people
subscribing to this ML, and I can't imagine how one would define, or
achieve, or identify, a "consensus" of that community, or why or how the
community would vote on anything, or what such the results of such a vote
would mean.

The very next step is to identify a champion. Such a champion would
presumably help to shape, review, and choose between alternatives for the
proposals. However, given the failure of my half-hearted efforts to find a
champion, and the fact that no one has emerged as champion over the several
years since these discussions started, allow me to be pessimistic.

It's odd to me because features such as property spread/rest notation, and
before that destructuring, have clearly demonstrated the appetite of the
"community" for language changes to better support manipulation of
properties--not surprising, since objects and their properties can be
considered the fundamental data structures of the language. This specific
proposal has a relatively small syntactic footprint in my opinion, and
measures up well against the majority of criteria that people commonly
apply to language design decisions and have been documented on this list. I
can only conclude that wiser minds than my own have concluded that this
particular feature simply does not rise to the level of priority of other
features that are progressing down the pipeline.

WIth regard to the notion of implementing this feature on a test basis, the
most obvious approach to doing that is as a Babel plug-in, but based on my
research--please-correct me if I'm wrong--Babel supports many kind of
transformations but not entirely new syntax as is the case here; that
requires essentialy rewriting internal parts of its parser. I have
experimented with a Sweet implementation with some success, but actually
I'm not really sure what that is supposed to demonstrate or if anyone would
care.

Bob

On Thu, May 30, 2019 at 12:29 AM guest271314 <guest271314 at gmail.com> wrote:

> Not a rule. Just an email to this board.
>
> On Thu, May 30, 2019 at 7:26 AM Григорий Карелин <grundiss at gmail.com>
> wrote:
>
>> I'm new to this community, so I'd appreciate if you clarify: is that your
>> opinion or is it kind of rule written somewhere?
>>
>> чт, 30 мая 2019 г. в 09:59, guest271314 <guest271314 at gmail.com>:
>>
>>> > Wouldn't it be better to consolidate the decision? I mean as OP I vote
>>> for `from`, but if majority will say they better like `x.{y, z}` I'll take
>>> it.
>>>
>>> No. There should not be any prohibition as to the additions different
>>> solutions to a single proposal. Neither proposal is "better" right now as
>>> neither have been coded, tested, and if necessary, specified. A simple
>>> majority does not mean correct or complete. The more approaches available
>>> the more ability to compose the code from different perspectives,
>>> outputting the same result; expanding the language both in syntax and reach
>>> as to possible composition, without setting an arbitrary specification to a
>>> single majority at only this point in time.
>>>
>>> The tersest have been able to achieve so far on a single line using an
>>> immediately invoked arrow function and object rest which requires writing
>>> the identifier twice.
>>>
>>> If part of the requirement for the proposal is terse code, following the
>>> pattern of an immediately invoked arrow function if  ```=``` operator
>>> between expressions ```()``` the arrow `>` and return value could be
>>> omitted as being designated implicit immediately invoked arrow function
>>> with default return value set from the destructured parameters, or
>>> ```undefined``` set as value of target identifiers, or plain object
>>> ```{}```, resulting in the syntax, within at least an object literal,
>>> possibly preceded by spread syntax, will result in
>>>
>>> ```let obj = {otherData:'other
>>> data',...(({firstName,lastName})=(user.profile)}```
>>>
>>> being equivalent to
>>>
>>> ```let obj = {otherData:'other
>>> data',...(({firstName,lastName})=>({firstName,lastName}))(user.profile)}```
>>>
>>>
>>> On Thu, May 30, 2019 at 6:38 AM Григорий Карелин <grundiss at gmail.com>
>>> wrote:
>>>
>>>> Wouldn't it be better to consolidate the decision? I mean as OP I vote
>>>> for `from`, but if majority will say they better like `x.{y, z}` I'll take
>>>> it.
>>>>
>>>> чт, 30 мая 2019 г. в 06:35, guest271314 <guest271314 at gmail.com>:
>>>>
>>>>> > I think it's possible to find someone who will represent the will of
>>>>> community.
>>>>>
>>>>> Individuals can compose the code right now.
>>>>>
>>>>> > At the moment the question is does community have will to add
>>>>> proposed sugar to the language, and if so, which version.
>>>>>
>>>>> Why would there be any restriction on the versions of syntax which
>>>>> would achieve the requirement? The original proposal using ```from``` and
>>>>> other proposals could each be created, tested, specified.
>>>>>
>>>>> On Wed, May 29, 2019 at 7:37 PM Григорий Карелин <grundiss at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> True
>>>>>>
>>>>>> I think it's possible to find someone who will represent the will of
>>>>>> community.
>>>>>>
>>>>>> At the moment the question is does community have will to add
>>>>>> proposed sugar to the language, and if so, which version.
>>>>>>
>>>>>> ср, 29 мая 2019 г. в 22:30, Oriol _ <oriol-bugzilla at hotmail.com>:
>>>>>>
>>>>>>> If you want to add this you will need a champion, see
>>>>>>> https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#new-feature-proposals
>>>>>>>
>>>>>>> -- Oriol
>>>>>>>
>>>>>>> El 29/5/19 a les 21:15, Григорий Карелин ha escrit:
>>>>>>>
>>>>>>> I agree.
>>>>>>>
>>>>>>> So, what does community think? Do we want to have “destructuring
>>>>>>> picking” sugar in JS and if we do, which syntax looks more attractive?
>>>>>>>
>>>>>>> I’d suggest to vote
>>>>>>>
>>>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190530/71168f65/attachment.html>


More information about the es-discuss mailing list