?. required to be one and two tokens · Issue #2 · tc39/proposal-hack-pipes (original) (raw)

This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Description

@fuchsia

In value |> ?.foo, ?. is tokenised as a single token (OptionalChainingPunctuator) so can't be resolved into ? and . by the grammar.

Using a "unary operator" for this case is a possible workaround, but it's not straightforward because ?.foo matches the extant OptionalChain production. And you've still got to allow for ? . value or (?).value. (If it wasn't for this case, you could just add ? to PrimaryExpression and then disallow it outside a pipeline.)

Also value |> ?.foo?.bar seems pretty confusing. So, as much as I love ?, it's probably the wrong character. (?% isn't a legal expression or a token...)

Other than that, count me as TeamHack. This proposal achieves left to right function evaluation, which is the main goal. And I think making value |> foo(?) look like a function is a gain - the first time you see it, you'll have a good guess at what's going on.

Metadata

Development

No branches or pull requests

Issue actions