improvement-proposals
improvement-proposals copied to clipboard
SIP-60 - Alternative bind patterns
This is the associated contributors thread.
The linked implementation is incomplete - I am happy to provide a more complete implementation at a later stage of the process.
About quoted patterns
One thing that would be worth investigating is: how does this interact with quoted patterns? /cc @nicolasstucki I think it's fine to just not support them at least initially, but that should be explicit in the SIP.
For the sake of this SIP, I would say that we do not support quoted patterns.
That said, the current specification should also work for quoted patterns (maybe partially). I would assume that this would be one of the use-cases
case '{ f($x: Int) } | '{ g($x: Double) } => x: Expr[Int] | Expr[Double]
The content of expression splices (the p in case '{ f(${p}) }) are patterns that could follow the same rules laid out in this SIP. While it should not be hard on the language level, there might be some extra complexity in the implementation due to the non-standard way quote patterns are typed.
Type variables in quoted patterns are another story, I am not sure if we can apply the same specification to these constructs, we would have to check if it is sound or can lead to confusion on the user level.
The SIP committee voted to accept this proposal as experimental, congratulations! There was consensus among the committee for the following changes:
- Drop support for given bind variables (if there is demand for them, they could be added back later)
- Rewrite the "Missing variables" section to always make it an error to miss a variable
@yilinwei Would you be willing to make these changes?
@smarter
Certainly; I am happy to make the changes. I am a little busy at the moment, so will get to within the next month or so.
Sounds good, thanks!
Hi @yilinwei, do you think you'll have time to make those changes? Otherwise no worries, I should be able to find some time soon.