Skip to content

Matching minor refactorings#13129

Merged
Octachron merged 3 commits intoocaml:trunkfrom
gasche:matching-minor-refactorings
Apr 30, 2024
Merged

Matching minor refactorings#13129
Octachron merged 3 commits intoocaml:trunkfrom
gasche:matching-minor-refactorings

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Apr 26, 2024

In parallel to #13121, here is another small PR in the review stack to fix The Pattern-Matching Bug.

(If you wonder about the state of this review stack, that is, when this damn thing is going to be fixed or at least you won't get emails about it anymore: I maintain an overview comment that describes the current best-known state. Currently I have 4 PRs to propose after this one, and the first 2 suffice to fix the bug.)

The present PR contains minor refactorings that should obviously not change the behavior of the pattern-matching compiler.

  • the first commit fixes a naming mistake I made in Matching: refactor to clarify the argument-passing structure #13084, where I introduced the name head to refer to "the head argument of an argument list" (once it is in "simple" form), without realizing that it conflicts with the pre-existing usage of head to refer to "the head of the pattern" (also called "discriminant", and a pretty important notion in division of matrices). The commit renames head::rest into first::rest again, and the type pure_head becomes pure_arg.
  • the second commit turns the tuple lambda * let_binding into a record with named fields, to prepare for the addition of a third field in an upcoming PR

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Apr 26, 2024

(cc the usual suspects: @ncik-roberts , @trefis, @lthls, maybe @Octachron and @voodoos if they want to; note that #13121 is also waiting for a reviewer, but reviewing that other PR involves slightly more domain knowledge )

Copy link
Copy Markdown
Contributor

@voodoos voodoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar (yet) with the lambda intermediate representation, but given the change only involves "minor refactorings that should obviously not change the behavior", I had a look.

The proposed refactoring does look correct to me and should not impact the behavior of the compilation. Additionally the use of a record instead of an anonymous couple makes the code slightly easier to read.

type args = (lambda * let_kind) list
type 'a arg = {
arg : 'a;
str : let_kind;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: str is quite a vague field name. It looks like a shortcut for structure, but it might not be so.

Copy link
Copy Markdown
Member Author

@gasche gasche Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str is the variable name that was previously used in the code in various places, so reusing it makes the diff less noisy thanks to punning

Copy link
Copy Markdown
Member Author

@gasche gasche Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but I can also rename the field and then rebase my later PRs with the new field name if that is your preference; which name would you suggest?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binding_kind? let_kind?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is mostly a waste of time, but the reviewer is king. I took 21 minutes to rename str into binding_kind.

gasche added 2 commits April 30, 2024 10:51
This avoids a naming conflict with 'head' as in "pattern head" that I
accidentally introduced recently.
Suggested-by: Florian Angeletti <florian.angeletti@inria.fr>
Copy link
Copy Markdown
Member

@Octachron Octachron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving on @voodoos behalf, and to make it clear that my nitpicking can be safely ignored.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Apr 30, 2024

Thanks! Would you by chance be interested in approving-on-behalf for #13121 as well?

@Octachron Octachron merged commit 9e912e8 into ocaml:trunk Apr 30, 2024
ncik-roberts added a commit to oxcaml/oxcaml that referenced this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants