-
Notifications
You must be signed in to change notification settings - Fork 444
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
RFC: removing let pattern matching #5216
Comments
Reasonable suggestion, although a bit counterintuitive for uses of Lean as a functional programming language. It may make sense for mathlib to implement a linter for this, and enforce this there (first), and if that works well reconsider if this should be the general rule for lean. |
I would really like to see this changed. I ran into this problem when writing simp theorems for simplifying code were I care about let bindings and let patterns on rhs of the theorem was not behaving as I expected. I would really like if I think that in my use case of simp theorems, an alternative solution could be to add something like |
I ran into this problem as well. It would be sweet if Alternatively, |
Result from triage team discussion: we agree that this behavior can be confusing, but the alternatives are confusing to programmers as well. It also conflicts with #3559. Thus we don't see a way to acceptance; a downstream linter like mentioned by Joachim would be a better approach. |
Proposal
Currently pattern matching with
let
doesn't keep the definition of the value. I believe this conflicts with the rest of the behavior oflet
and is confusing, especially for new users (example 1, example 2, example 3), and so should be removed or linted against, andhave pattern := value
will have to be used instead.An alternative option is to change it to keep the value, e.g.
let (a, b) := l
will behave likelet a := l.1; let b := l.2
, but this will require more effort.Community Feedback
Zulip discussion.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: