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/2019-05-24-15th-dotty-milestone-release.md
+14-18Lines changed: 14 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ authorImg: /images/anatolii.png
6
6
date: 2019-05-24
7
7
---
8
8
9
-
Hi! In this article, we'd like to announce the 15th release of Dotty. With this release comes a bunch of improvements
9
+
Hi! In this article, we'd like to announce the 15th release of Dotty. With this release comes a bunch of new features and improvements, such as the ability to enforce whether an operator is intended to be used in an infix position, the type safe pattern bindings and more.
10
10
11
11
This release serves as a technology preview that demonstrates new
12
12
language features and the compiler supporting them.
@@ -27,12 +27,12 @@ You can learn more about Dotty on our [website](https://dotty.epfl.ch).
27
27
28
28
<!--more-->
29
29
30
-
This is our 14th scheduled release according to our
# What’s new in the 0.15.0-RC1 technology preview?
34
34
## Operator Rules
35
-
This change addresses the problem of the regulation of whether an operator is supposed to be used in an infix position. The motivation is for the library authors to be able to enforce whether a method or a type is supposed to be used in an infix position by the users.
35
+
This change addresses the problem of the regulation of whether an operator is supposed to be used in an infix position. The motivation is for the library authors to be able to enforce whether a method or a type is supposed to be used in an infix position by the users. This ability will help to make code bases more consistent in the way the calls to methods are performed.
36
36
37
37
Methods with symbolic names like `+` are allowed to be used in an infix position by default:
38
38
@@ -44,7 +44,7 @@ scala> Foo(1) + Foo(2)
44
44
valres0:Int=3
45
45
```
46
46
47
-
Methods with alphanumeric names are not allowed to be used in an infix position by default. Breaking this constraint will raise a deprecation warning:
47
+
Methods with alphanumeric names are not allowed to be used in an infix position. Breaking this constraint will raise a deprecation warning:
48
48
49
49
```scala
50
50
scala>caseclassFoo(x: Int) { defplus(other: Foo) = x + other.x }
@@ -62,7 +62,7 @@ scala> Foo(1).plus(Foo(2))
62
62
valres2:Int=3
63
63
```
64
64
65
-
As the warning says, if you want the users of your library to be able to use it in an infix position, you can do so as follows:
65
+
As the warning says, if you want the users of the method to be able to use it in an infix position, you can do so as follows:
66
66
67
67
```scala
68
68
scala>importscala.annotation.infix
@@ -74,11 +74,9 @@ scala> Foo(1) plus Foo(2)
74
74
valres3:Int=3
75
75
```
76
76
77
-
The above change will allow for more consistency across the code base, as the author of a method is able to make a decision on how the method is supposed to be called.
78
-
79
77
To smoothen the migration, the deprecation warnings will only be emitted if you compile with the `-strict` flag under Dotty 3. Alphanumeric methods that are defined without the `@infix` annotation used in an infix position will be deprecated by default starting with Dotty 3.1.
80
78
81
-
For more information, see the [documentation](http://dotty.epfl.ch/docs/reference/changed-features/operators.html#the-infix-annotation). Note that the `@alpha` annotation also described in the documentation is a work in progress and is not available in this release.
79
+
For more information, see the the [documentation](http://dotty.epfl.ch/docs/reference/changed-features/operators.html#the-infix-annotation). Note that the `@alpha` annotation also described in the documentation is planned for the future and is not available in this release.
82
80
83
81
## `given` clause comes last
84
82
In the previous release, you could write something like this:
@@ -99,15 +97,15 @@ Now, however, `given` clauses must come last. The above code will fail with:
99
97
one error found
100
98
```
101
99
102
-
The following code is the correct way to express the program in question:
100
+
The following snippet is the correct way to express the program in question:
103
101
104
102
```scala
105
103
implied forString="foo"
106
104
deff(x: Int)(z: Int) given (y: String) = x + z
107
105
f(1)(3)
108
106
```
109
107
110
-
This change is done to reduce confusion when calling functions with mixed explicit and implied parameters.
108
+
We changed this to reduce confusion when calling functions with mixed explicit and implied parameters.
111
109
112
110
## Type-safe Pattern Bindings
113
111
```scala
@@ -128,10 +126,8 @@ Dotty compiler will allow such a pattern binding only if the pattern is *irrefut
128
126
If we want to force the pattern binding if the pattern is not irrefutable, we can do so with an annotation:
129
127
130
128
```scala
131
-
scala>valxs:List[Any] =List("1", "2", "3")
132
-
|val (x: String) ::_: @unchecked = xs
133
-
valx:String=1
134
-
valxs:List[Any] =List(1, 2, 3)
129
+
valxs:List[Any] =List("1", "2", "3")
130
+
val (x: String) ::_: @unchecked = xs
135
131
```
136
132
137
133
The same is implemented for pattern bindings in `for` expressions:
@@ -142,12 +138,12 @@ The same is implemented for pattern bindings in `for` expressions:
142
138
// than the right hand side expression's type Any
143
139
```
144
140
145
-
For the migration purposes, the above change will only take effect in Dotty 3.1 by default. You can use it from Dotty 3 with the `-strict` flag.
141
+
For the migration purposes, the above change will only take effect in Dotty 3.1. You can use it in Dotty 3 with the `-strict` flag.
146
142
147
143
For more information, see the [documentation](http://dotty.epfl.ch/docs/reference/changed-features/pattern-bindings.html).
148
144
149
-
## Further improvements to GADT support
150
-
In this release, we've further improved our support for Generalised Algebraic Data Types (GADTs). Most notably, we now support variant GADTs:
145
+
## Further improvements to Generalised Algebraic Data Types (GADTs) support
146
+
In this release, we've further improved our support for GADTs. Most notably, we now support variant GADTs:
0 commit comments