improvement-proposals icon indicating copy to clipboard operation
improvement-proposals copied to clipboard

SIP-60 - Alternative bind patterns

Open yilinwei opened this issue 1 year ago • 5 comments

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.

yilinwei avatar Jan 18 '24 11:01 yilinwei

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.

nicolasstucki avatar Jan 30 '24 13:01 nicolasstucki

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 avatar Mar 15 '24 15:03 smarter

@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.

yilinwei avatar Mar 17 '24 21:03 yilinwei

Sounds good, thanks!

smarter avatar Mar 17 '24 21:03 smarter

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.

smarter avatar Jun 21 '24 13:06 smarter