Iltotore / iron

Strong type constraints for Scala
https://iltotore.github.io/iron/docs/
Apache License 2.0
427 stars 37 forks source link

Better String support at compile-time #238

Closed Iltotore closed 2 weeks ago

Iltotore commented 1 month ago

When evaluating a String at compile-time, concatenated Strings are supported:

"abc" + "def"

but these alternatives are not supported:

Automatic toString

"abc" + 123

String interpolation

inline val x = 123
"abc$x"

When #227 is completed, it would improve usability of String constraints at compile-time.

Iltotore commented 1 month ago

Unfortunately, Dotty does very less desugaring/reduction for these two examples. Supporting these alternatives would imply adding much complexity for little gains.

It seems that this case is already handled by scala.quoted.FromExpr which what the new ExprDecoder is based on so adding interpolation support, while less trivial than concatenation, might still be possible.