Re the import scala.compiletime.companion
idea: I think it wouldn’t really buy us much because it would still have very special semantics.
Let’s take a very simple example like
import scala.compiletime.companion as <>
class Foo(x: Int)
val foo: Foo = <>(42)
The issue here is that the expression that we need to figure out a type for in order to compile this is <>
, but the expression that that type needs to be determined from is <>(42)
, not <>
. This is completely different from how any kind of identifier in Scala today works, it will require support from the compiler, and hence I disagree about the idea that there are “no new principles to learn” here – there definitely are. And I think hiding very different behaviour behind a familiar syntax is actually more confusing than just having a separate syntax, like we do for _
lambda expressions, which are the most similar feature that we have today.