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

more idiomatic if-statements in pattern matches #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stuebinm
Copy link
Collaborator

this implements the suggestions given in #5.

To remove extra {} blocks in the translation of multi-equation functions, this introduces a new reordering of patterns: we first check patterns which actually deconstruct something (i.e. which are an IConst or application), and only then apply the renamings for patterns which consist only of an IVar.

This ensures that even without the {} block we won't "leak" variables into the scope of other function equations, since we're guaranteed to already be within at least one if-statement, which is itself its own scope.

(tbh, i'm a little sceptical about this idea of reordering patterns; I can't see how it would break anything, and the Codegenerator_Test still runs through fine, but at the very least it feels a little hard to nicely describe what it does in readable notation and without any hand-waving)

this implements the suggestions given in #5.

To remove extra {} blocks in the translation of multi-equation functions,
this introduces a new reordering of patterns: we first check patterns which
actually deconstruct something (i.e. which are an IConst or application),
and only then apply the renamings for patterns which consist only of an IVar.

This ensures that even without the {} block we won't "leak" variables into
the scope of other function equations, since we're guaranteed to already be
within at least one if-statement, which is itself its own scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant