Syntax proposal `if let`
Open
Nobody has claimed this yet.
Parser
RFC
- Dominant language
- OCaml
- Stars
- 10.3k
- Forks
- 438
- PR merge metrics
- No merged PRs in 30d
Description
In swift, there's this nice construct for simple destructuring
if case .someEnumVariant(let value) {
...
} else {
...
}
It's basically a one-armed match.
It would be super handy to have that for reason, and I imagine it would look like
if let [%pattern] = [%value] {
// x
} else {
// y
}
which we'd translate to
switch [%value] {
| [%pattern] => // x
| _ => // y
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the proposed if let form with the existing switch form described in the issue. The issue names no files, tests, or entry points. Done would require an agreed syntax and corresponding implementation and tests, but the work appears to be an open design proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100