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
Copy file name to clipboardExpand all lines: docs/docs/reference/unused-terms.md
+3-5Lines changed: 3 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,7 @@ m.turnedOn.turnedOn // ERROR
34
34
35
35
Note that in the code above the actual implicit arguments for `IsOff` are never used at runtime; they serve only to establish the right constraints at compile time.
36
36
As these parameters are never used at runtime there is not real need to have them around, but they still need to be
37
-
present at runtime to be able to do separate compilation and retain binary compatiblity. Unused parameters are contractually
38
-
obligated to not be used at runtime, enforcing the essence of evidences on types and allows them to always be optimized away.
39
-
37
+
present at runtime to be able to do separate compilation and retain binary compatiblity.
40
38
41
39
How to define unused parameter?
42
40
-------------------------------
@@ -49,7 +47,7 @@ val lambdaWithUnusedEv: unused Ev => Int =
49
47
unused (ev: Ev) =>42
50
48
```
51
49
52
-
Those parameters will not be usable for computations, thought they can be used as arguments to other `unused` parameters.
50
+
`unused` parameters will not be usable for computations, though they can be used as arguments to other `unused` parameters.
53
51
54
52
```scala
55
53
defmethodWithUnusedInt1(unused i: Int):Int=
@@ -84,7 +82,7 @@ methodWithUnusedEv(evidence1)
84
82
85
83
State machine with unused evidence example
86
84
------------------------------------------
87
-
The following examples is an extended implementation of a simple state machine which can be in a state `On` or `Off`.
85
+
The following example is an extended implementation of a simple state machine which can be in a state `On` or `Off`.
88
86
The machine can change state from `Off` to `On` with `turnedOn` only if it is currently `Off`,
89
87
conversely from `On` to `Off` with `turnedOff` only if it is currently `On`. These last constraint are
90
88
captured with the `IsOff[S]` and `IsOn[S]` implicit evidence only exist for `IsOff[Off]` and `InOn[On]`.
0 commit comments