Skip to content

Special syntax for type quotes and type splices is redundant #9486

Closed
@nicolasstucki

Description

@nicolasstucki

Currently, we can create a quoted.Type[X] with

val t1: Type[X] = '[X] // special syntax
val t2: Type[X] = Type[X] // Type.apply method
val t2: Type[X] = summon[Type[X]] // given by Type.apply

the first two are equivalent as '[X] is typed as Type[X] which is just a call to the function Type.apply. Most of the time this type is not generated by hand, it is just summoned for some contextual parameter. Hence the special syntax '[...] is redundant.


On the other side, using a quoted.Type[X] can be done with

def f[X](using QuoteContext)(using t: Type[X]) = '{
  val t1: $t = ??? // special syntax
  val t2: t.T = ??? // accessed directly
  val t3: X = ??? // healed using t.T
}

both are equivalent as '$t is typed as t.T which is just a member selection. Most of the type we use directly X which gets healed to t.T. Hence the special syntax $t is redundant.


Furthermore, we used quotes and splices for both expressions and types because in the beginnings we thought that they behaved similarly level-wise. But now that we realized that this is not true, this similarity in syntax only leads to confusion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions