Opinions about @ binding in patterns

Scala 2 distinguishes varid binding case C(v) or non-var case C(V) from at-binding case C(V @ _).

The motivation was to allow more flexible bindings which are otherwise not expressible:

case `type` @ _ =>

In other words, @ syntax is an “escape hatch” for the “lowercase variable identifier” rule.

The other use case is that mechanical transforms need not be overly finicky about the identifier in @ syntax.

The currently languishing Dotty ticket is this one.

I’m opening this topic in order to resolve what ought to be an uncontroversial niche use case.

If there are no compelling controverting arguments, will I submit a PR to Dotty? Maybe.

The other purpose of this topic is to subvert “won’t fix on Dotty because what a hassle.”

Possibly no one will base their decision whether to migrate to Scala 3 on the outcome of this ticket.

I happened to notice the issue while browsing my open tickets, because I feel that if I open an OSS ticket, I ought to attempt to close it.

2 Likes

This change was not intentional. We should keep the Scala 2 rules here. So, please open a PR!

2 Likes