Skip to content

Commit 4f7b2c6

Browse files
committed
Merge pull request #1 from philwills/multiple-implicit-params-sip-edit
Minor edits for clarity of SIP
2 parents ebe6ba6 + 00cd664 commit 4f7b2c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sips/pending/_posts/2016-04-21-multiple-implicit-parameter-lists.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ title: SIP-NN - SIP Allow multiple implicit parameter lists
1414

1515
## Motivation
1616

17-
In Scala the implicit parameters of a function are limited to being placed in the single very last parameter list of a function. This prevents later parameters from using dependant types of former ones as this is only allowed between, but not inside a single parameter list. Another issue introduced by this restriction is, that if you want to explicitly specify one of the implicit parameters you have to specify all of them by hand (or write `implicitly` in place of every other parameter that should be filled by the compiler).
17+
Currently, the implicit parameters of a function are limited to being placed in a single, final, parameter list of a function. This prevents later parameters from using dependant types of former ones, as this is only allowed between, but not inside a single parameter list.
18+
19+
This restriction also means that if you want to explicitly specify one of the implicit parameters you have to specify all of them by hand (or write `implicitly` in place of every other parameter that should be filled by the compiler).
1820

1921
## Motivating Examples
2022

@@ -26,7 +28,7 @@ trait A { type B }
2628

2729
def works(a: A)(b: a.B) = "works"
2830
{% endhighlight %}
29-
Due to the restriction of being contained in a single parameter list the implicits can't benefit from this goodness. A common workaround is to pull the type member `B` into a type parameter of a new `Aux` object and having this as a type parameter of your function:
31+
Due to the restriction of being contained in a single parameter list, implicit parameters can't work in the same way. A common workaround is to pull the type member `B` into a type parameter of a new `Aux` object and make this a type parameter of your function:
3032
{% highlight scala %}
3133
trait A { type B }
3234
object A { type Aux[D] = A { type B = D } }
@@ -53,7 +55,7 @@ then(1)
5355

5456
## Implementation
5557

56-
The implementation of this change is as simple as removing the artificial restriction of having only one parameter list in the `Parser`. A pull request (#5108) from Miles Sabin already implements this change as well as an accompanying test file. The change should not affect any existing code as every Scala statement that was valid before will still be valid after the change. There will even be binary compatibility in both directions.
58+
The implementation of this change is as simple as removing the restriction of having only one parameter list in the `Parser`. A pull request (#5108) from Miles Sabin already implements this change as well as an accompanying test file. The change should not affect any existing code as every Scala statement that was valid before will still be valid after the change. There will even be binary compatibility in both directions.
5759

5860
## Drawbacks
5961

0 commit comments

Comments
 (0)