Skip to content

Commit 1fc0efe

Browse files
authored
Merge pull request #56 from Sporarum/patch-2
Cleanup SIP-47 - Clause Interleaving
2 parents 7675a25 + a5f8c9f commit 1fc0efe

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

content/clause-interleaving.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ def foo[A](using a: A)(b: List[A])[C <: a.type, D](cd: (C, D))[E]: Foo[A, B, C,
3030

3131
## Motivation
3232

33-
We motivate the feature with two use cases:
34-
35-
* a `getOrElse` method for a heterogeneous key-value store, which is an occurrence of wanting a type parameter whose bounds are path-dependent on a term parameter, and
36-
37-
### Heterogeneous key-value store
3833
Consider an API for a heterogenous key-value store, where keys know what type of value they must be associated to:
3934
~~~ scala
4035
trait Key:
@@ -83,7 +78,6 @@ While again, this provides the expected API at call site, it also has issues:
8378
* The behavior is not the same, as `default` has to be a by-value parameter
8479
* The definition is hard to visually parse, as users are more used to methods (and it is our opinion this should remain so)
8580
* The definition is cumbersome to write, especially if there are a lot of term parameters
86-
* Methods containing curried type clauses like `def foo[A][B](x: B)` cannot be represented in this way, as polymorphic methods always have to have a term parameter right after.
8781
* It is inefficient, as many closures must be created for each call to `getOrElse` (one per term clause to the right of the first non-initial type clause).
8882
* Same problem as above with overloading
8983

@@ -123,7 +117,7 @@ Param ::= id ‘:’ ParamType [‘=’ Expr]
123117

124118
The main rules of interest are `DefParamClauses` and `DefParamClauseChunk`, which now allow any number of type parameter clauses, term parameter clauses and using parameter clauses, in any order as long as there are no two adjacent type clauses.
125119

126-
Note that these are also used for the right-hand side of extension methods, clause interleaving thus also applies to them.
120+
Note that these are also used for the right-hand side of extension methods, thus clause interleaving also applies to them.
127121

128122
It is worth pointing out that there can still only be at most one implicit parameter clause, which, if present, must be at the end.
129123

0 commit comments

Comments
 (0)