Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

?. required to be one and two tokens #2

@fuchsia

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

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions