matching: refactor compile_match* to clarify argument binding#13074
Merged
gasche merged 1 commit intoocaml:trunkfrom Apr 5, 2024
Merged
matching: refactor compile_match* to clarify argument binding#13074gasche merged 1 commit intoocaml:trunkfrom
gasche merged 1 commit intoocaml:trunkfrom
Conversation
Currently the code of compile_match_nonempty is a bit strange, because it replaces an arbitrary expression `arg` by a variable in the argument list of the pattern-matching matrix, but it is not clear which of the two versions will be used to generate code by the sub-functions it calls. This commit is a minor refactoring to move the variable binding close to the place where the expression argument is turned into a variable argument.
Member
Author
|
Woah! Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the code of
compile_match_nonemptyis a bit strange, because it replaces an arbitrary expressionargby a variable in the argument list of the pattern-matching matrix, but it is not clear which of the two versions will be used to generate code by the sub-functions it calls.This commit is a minor refactoring to move the variable binding close to the place where the expression argument is turned into a variable argument.
The current oddity came up indirectly in the review of #12555 by @ncik-roberts, and I think that this refactoring would have made the code easier to think about and discuss. I am proposing the refactoring to cleanup this aspect now. It should be "obviously" correct in the sense that it exactly preserves the previous behavior, with just some restructuring of the split into functions.