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

Make variant pattern matching not rely on tags being int #6085

Merged
merged 5 commits into from
Mar 21, 2023

Conversation

cristianoc
Copy link
Collaborator

There are several ways in which the compilation of variants relies on tags being integers:

  • Sometimes it uses booleans if x to mean x !=0 to mean: not the first variant (i.e. tag 0)
  • Sometimes it uses intervals if (x > 3 || x < 1)

Care is required not to change the compilation of variants with special compilation:

  • true and false
  • lists have constructors "[]" and "::"
  • options have a specific definition for "Some" and "None"

There are several ways in which the compilation of variants relies on tags being integers:
- Sometimes it uses booleans `if x` to mean `x !=0` to mean: not the first variant (i.e. tag 0)
- Sometimes it uses intervals `if (x > 3 || x < 1)`

Care is required not to change the compilation of variants with special compilation:
- true and false
- lists have constructors "[]" and "::"
- options have a specific definition for  "Some" and "None"

See #6077
The only one that could still make sense is for the identity function, but that would be a strange optimization.
Better have it earlier on, and apply to partial cases too, where it's mostly the identity.
@cristianoc cristianoc merged commit 40fc40b into master Mar 21, 2023
@cristianoc cristianoc deleted the pattern_match_variant branch March 21, 2023 10:34
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.

None yet

1 participant