[Proposal] Optional spreading

Jordan Harband ljharb at gmail.com
Sun Feb 16 06:57:33 UTC 2020


No, it wouldn't - see https://github.com/tc39/ecma262/pull/1069.

On Sat, Feb 15, 2020 at 11:54 AM Bob Myers <rtm at gol.com> wrote:

> Wouldn't simply making array spreading ignore nullish values be backward
> compatible?
> Unless one imagines that people are depending on this being an error
> somehow.
>
> On Sat, Feb 15, 2020 at 10:05 AM Jordan Harband <ljharb at gmail.com> wrote:
>
>> Since object spread already ignores nullish values, a syntax change would
>> only be needed for array spread. Then, the two kinds of spread would
>> support different syntactic features, which seems inconsistent.
>>
>> On Sat, Feb 15, 2020 at 7:56 AM Beknar Askarov <beknaraskarov at gmail.com>
>> wrote:
>>
>>> Thank you, everyone, for feedback. Sorry for not getting back for a
>>> while. I had some time to think and concluded that nullish noop in
>>> spreading is a good feature to be added to the language without
>>> complicating it too much.
>>> So please take a look at the explainer
>>> <https://gist.github.com/askbeka/8bb17508ec250a789ea9bff683a50e38> and
>>> lets discuss in es-discourse proposal
>>> <https://es.discourse.group/t/optional-spreading-proposal/224>, if you
>>> have further feedback, please share
>>>
>>> On Fri, Aug 23, 2019 at 7:18 PM Herby Vojčík <herby at mailbox.sk> wrote:
>>>
>>>> On 23. 8. 2019 16:24, Beknar Askarov wrote:
>>>> > @Scott Rudiger After thinking more about it.
>>>> > I would not like to conflict with semantics of optional chaining and
>>>> > null coalescing operator.
>>>> > So in order to not confuse people, maybe introduce two types of
>>>> optional
>>>> > spread operators
>>>> >
>>>> >
>>>> > 1. `?...` - Do not spread if nullish. Note nullish. Else try to
>>>> spread.
>>>> > Signature Array: [?...(nullish | Iterable)];
>>>> > Signature Object: {?...(nullish | object)};
>>>> >
>>>> > 2. `!...` - Do not spread if false. Note FALSE not falsy. Else try to
>>>> > spread.
>>>>
>>>> I read
>>>>
>>>>    !...foo
>>>>
>>>> as
>>>>
>>>>    !(...foo)
>>>>
>>>> that is, logical not. I'd tip it already works that way. In which case
>>>> no go, break compat.
>>>>
>>>> Herby
>>>>
>>>> > Signature Array: [!...(false | Iterable)];
>>>> > Signature Object: {!...(false | object)};
>>>> >
>>>> > I think this can be an option to avoid consfusion
>>>>
>>>> Or add a new one. :-(
>>>>
>>> _______________________________________________
>> 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/20200215/7080d3e8/attachment.html>


More information about the es-discuss mailing list