Skip to content

Short closures using ==> syntax #3945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed

Conversation

nikic
Copy link
Member

@nikic nikic commented Mar 14, 2019

This is based on top of #3941 and implements a short closure variant that uses ($x) ==> $x * $y syntax. As mentioned in the RFC, this requires lexer scanahead, which is implemented here in proof of concept form. The actual implementation would want to also store the scanahead tokens so they can be replayed rather than relexed.

I tried getting the same to work for the ($x) => $x * $y syntax, but couldn't figure out how to do this. The problem is that some ( will be incorrectly classified as T_ARROW_START, and we need additional productions to ensure that T_ARROW_START expr ')' T_DOUBLE_ARROW is not interpreted as an arrow function inside arrays and yields. I haven't figured out how to avoid the resulting conflicts.

@nikic
Copy link
Member Author

nikic commented Apr 21, 2019

Closing this, as I went with #3941 in the end.

@nikic nikic closed this Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants