[Proposal] Optional spreading

Beknar Askarov beknaraskarov at gmail.com
Sat Feb 15 15:55:52 UTC 2020


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. :-(
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200215/3c2a9328/attachment.html>


More information about the es-discuss mailing list