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/blog/_posts/2018-03-05-seventh-dotty-milestone-release.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -71,28 +71,28 @@ object Option {
71
71
You can visit our website for more information about [enumerations](/docs/reference/enums/enums.html)
72
72
and how we can use them to model [Algebraic Data Types](/docs/reference/enums/adts.html).
73
73
74
-
### Unused Parameters[#3342](https://github.com/lampepfl/dotty/pull/3342) and remove Phantom types [#3410](https://github.com/lampepfl/dotty/pull/3410)
75
-
The keyword `unsued` can be placed on parameters, `val` and `def` to enforce that no reference to
74
+
### Ghost terms[#3342](https://github.com/lampepfl/dotty/pull/3342) and remove Phantom types [#3410](https://github.com/lampepfl/dotty/pull/3410)
75
+
The keyword `ghost` can be placed on parameters, `val` and `def` to enforce that no reference to
76
76
those terms is ever used (recursively). As they are never used, they can safely be removed during compilation.
77
-
These have similar semantics as _phantom types_ but with the added advantage that any type can be an unused parameter. They can be used to add implicit type constraints that are only relevant at compilation time.
77
+
These have similar semantics as _phantom types_ but with the added advantage that any type can be an ghost parameter. They can be used to add implicit type constraints that are only relevant at compilation time.
78
78
79
79
```scala
80
80
// A function that requires an implicit evidence of type X =:= Y but never uses it.
81
81
// The parameter will be removed and the argument will not be evaluated.
82
-
defapply(implicitunusedev: X=:=Y) =
82
+
defapply(implicitghostev: X=:=Y) =
83
83
foo(ev) // `ev` can be an argument to foo as foo will also never use it
84
-
deffoo(unusedx: X=:=Y) = ()
84
+
deffoo(ghostx: X=:=Y) = ()
85
85
```
86
86
87
87
The previous code will be transformed to the following:
88
88
89
89
```scala
90
-
defapply() =//unused parameter will be removed
91
-
foo() // foo is called without the unused parameter
92
-
deffoo() = () //unused parameter will be removed
90
+
defapply() =//ghost parameter will be removed
91
+
foo() // foo is called without the ghost parameter
0 commit comments