You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which is different from the expression syntax where we write given Type or given name as Type, aligning ourselves would be nice, although the as syntax isn't so useful since we can use pattern bindings name @ given Type or name as given Type after #9837, so we could support only the given Type syntax.
The text was updated successfully, but these errors were encountered:
In the Dotty meeting the consensus was to keep only the anonymous given Type syntax. If a name is desired, it can be added with a as binder as in other patterns. I.e. the example would be
def f1[T](x: Ordering[T]) = (x, x) match {
case (given Ordering[T], _) => new TreeSet[T]
}
def f4[T](x: Ordering[T]) = {
val xs = List(x, x, x)
for given Ordering[T] <- xs
yield new TreeSet[T]
for x as given Ordering[T] <- xs
yield new TreeSet[T]
}
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Oct 26, 2020
Currently the syntax for given in patterns looks like:
Which is different from the expression syntax where we write
given Type
orgiven name as Type
, aligning ourselves would be nice, although theas
syntax isn't so useful since we can use pattern bindingsname @ given Type
orname as given Type
after #9837, so we could support only thegiven Type
syntax.The text was updated successfully, but these errors were encountered: