String interpolation in pattern matching

There are interesting discussion:
-Better number literals (Better number literals)
-Bigdecimal literal (Bigdecimal literal)

We also widely use custom types in our framework (to provide 3vl for better database integration):
-date
-Number
-String

The best way to construct these types is string interpolation.

I agree that:

I think, if there is the ability to use string interpolation in pattern matching the most difficulties will be solved.

If support for “unapply” is implemented:

implicit class ExtendedLongHelper(val sc: StringContext) extends AnyVal {
  def el(args: Any*): Long = ???
  def unapply(args: Any*):Boolean = ???
}

There will be ability to write:

val l = el”1000_4332_24”
l match {
  case el”1000_4332_24” => println( “good :)” )
}

That ability already exists, see SIP-11 - String Interpolation | Scala Documentation

Thank you.

Would it be posible to add this abiity to Scala specification syntax summary?
https://scala-lang.org/files/archive/spec/2.12/13-syntax-summary.html

It is a big suprise, when any standard ability works if it is absence in syntax summary.

I agree that taking SIPs as endless supplements to the spec is confusing.

3 Likes

Pull requests merging past SIPs into the Scala spec would be exceedingly welcome.

1 Like
1 Like

Seth is exceedingly welcoming.

2 Likes