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
We now forbid given clauses followed by normal parameter clauses.
besides the syntactic awkwardness, there's also the problem
of eta expansion. Example:
```
trait Universe { type T }
def f given (u: Universe) (x: u.T)
```
How should we tea expand `f`? The usual algorithm would give:
```
(x: u.T) => (f given the[Universe])(x)
```
but that's ill typed, since `u` is not defined on the outside.
deffgiven (u: Universe) given (x: u.Context) = ...
72
+
```
73
+
However, all `given` clauses in a definition must come after any normal parameter clauses.
74
+
Multiple given clauses are matched left-to-right in applications. Example:
75
+
```scala
76
+
implied global forUniverse { typeContext= ... }
77
+
implied ctx for global.Context { ... }
77
78
```
78
79
Then the following calls are all valid (and normalize to the last one)
79
80
```scala
80
-
f("abc")
81
-
(f givenglobal)("abc")
82
-
f("abc") givenctx
83
-
(f givenglobal)("abc") givenctx
81
+
f
82
+
(f givenglobal)
83
+
(f givenglobal) givenctx
84
84
```
85
+
But `f given ctx` would give a type error.
85
86
86
87
## Summoning Implied Instances
87
88
@@ -100,13 +101,14 @@ Functions like `the` that have only context parameters are also called _context
100
101
101
102
Here is the new syntax of parameters and arguments seen as a delta from the [standard context free syntax of Scala 3](http://dotty.epfl.ch/docs/internals/syntax.html).
0 commit comments