Skip to content
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

Refactor dispatch!; fixes #344 #527

Closed
wants to merge 1 commit into from

Conversation

silvanshade
Copy link

This PR fixes #344.

There may be a simpler way to factor the rules but I couldn't find one easily.

The main reason for the complexity is that handling the trailing comma differently (depending on block or simple expression) requires separate rules. This is because alternation cannot be expressed in the rule patterns and the workaround is to use recursion.

Additionally, macros cannot expand in match arm positions, so an accumulator pattern must be used, rather than immediately expanding a match arm and then recursing.

This also has the potential to make the macro expansion for dispatch slower (particularly on very large branches, due to the inherent re-parsing of the token trees) but I haven't tested how much of an impact that has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dispatch shouldn't require comma after {} arm
1 participant