Proposal: Selector/Select Expression

Isiah Meadows isiahmeadows at gmail.com
Fri Jun 28 15:32:41 UTC 2019


Note: the wildcard syntax `?.foo` would itself not require this. It'd
require a space after the `?` in ternaries if the Elvis operator proposal
`a ?? b` comes along (and a grammatical edit isn't made to clarify `??.`
gets parsed as `? ?.`), but it would not otherwise be ambiguous.

On Fri, Jun 28, 2019 at 11:25 Isiah Meadows <isiahmeadows at gmail.com> wrote:

> Agreed in that it's not ambiguous - you have to disambiguate it with a
> space for the same reason you have to use `a+ +b` instead of `a++b` in
> minified code to avoid ambiguity when specifying `a + +b`. So `a?.b:.c`
> would be invalid, but `a? .b:.c` is not.
>
> On Thu, Jun 27, 2019 at 16:48 Bob Myers <rtm at gol.com> wrote:
>
>> Not exactly, since the optional chaining operator is `?.` with no space
>> in between.
>>
>> On Thu, Jun 27, 2019 at 1:37 PM Simon Farrugia <simonfarrugia26 at gmail.com>
>> wrote:
>>
>>> Also, without a leading token, a selector expr with the optional
>>> chaining operator inside a ternary operator would be ambiguous.
>>>
>>> ```
>>>
>>> const contactSelector = true ? .contacts.email : .contacts.phone;
>>>
>>> ```
>>>
>>>
>>> --
> -----
>
> Isiah Meadows
> contact at isiahmeadows.com
> www.isiahmeadows.com
>
-- 
-----

Isiah Meadows
contact at isiahmeadows.com
www.isiahmeadows.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190628/b1fb96b2/attachment.html>


More information about the es-discuss mailing list