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/changed-features/implicit-resolution.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
layout: doc-page
3
3
title: "Changes in Implicit Resolution"
4
4
---
5
-
This page describes changes to the implicit resolution that apply both to the new `given`s and to the old-style `implicit`s in Dotty.
5
+
This page describes changes to the implicit resolution that apply both to the new `given`s and to the old-style `implicit`s in Scala 3.
6
6
Implicit resolution uses a new algorithm which caches implicit results
7
7
more aggressively for performance. There are also some changes that
8
8
affect implicits on the language level.
@@ -114,7 +114,7 @@ the implicit search for `Q` fails.
114
114
**5.**The treatment of divergence errors has also changed. A divergent implicit is treated asa normal failure, after which alternatives are still tried. This also makes sense: Encountering a divergent implicit means that we assume that no finite solution can be found on the corresponding path, but another path can still be tried. By contrast,
115
115
most (but not all) divergence errors in Scala2 would terminate the implicit search asa whole.
116
116
117
-
**6.**Scala-2 gives a lower level of priority to implicit conversions with call-by-name parameters relative to implicit conversions with call-by-value parameters. Dottydrops this distinction. So the following code snippet would be ambiguous in Dotty:
117
+
**6.**Scala-2 gives a lower level of priority to implicit conversions with call-by-name parameters relative to implicit conversions with call-by-value parameters. Scala3drops this distinction. So the following code snippet would be ambiguous in Scala3:
Copy file name to clipboardExpand all lines: docs/docs/reference/changed-features/interpolation-escapes.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: Escapes in interpolations
5
5
6
6
In Scala 2 there was no straightforward way to represent a single quote character `"` in a single quoted interpolation. A `\` character can't be used for that because interpolators themselves decide how to handle escaping, so the parser doesn't know whether the `"` should be escaped or used as a terminator.
7
7
8
-
In Dotty, you can use the `$` meta character of interpolations to escape a `"` character.
8
+
In Scala 3, you can use the `$` meta character of interpolations to escape a `"` character.
Copy file name to clipboardExpand all lines: docs/docs/reference/changed-features/pattern-matching.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ layout: doc-page
3
3
title: "Option-less pattern matching"
4
4
---
5
5
6
-
Dotty implementation of pattern matching was greatly simplified compared to Scala 2. From a user perspective, this means that Scala 3 generated patterns are a *lot* easier to debug, as variables all show up in debug modes and positions are correctly preserved.
6
+
The implementation of pattern matching in Scala 3 was greatly simplified compared to Scala 2. From a user perspective, this means that Scala 3 generated patterns are a *lot* easier to debug, as variables all show up in debug modes and positions are correctly preserved.
7
7
8
-
Dotty supports a superset of Scala 2 [extractors](https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#extractor-patterns).
8
+
Scala 3 supports a superset of Scala 2 [extractors](https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#extractor-patterns).
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/derivation.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -122,12 +122,12 @@ Mirror.Product {
122
122
Note the following properties of `Mirror` types,
123
123
124
124
+ Properties are encoded using types rather than terms. This means that they have no runtime footprint unless used and
125
-
also that they are a compile time feature for use with Dotty's metaprogramming facilities.
125
+
also that they are a compile time feature for use with Scala 3's metaprogramming facilities.
126
126
+ The kinds of `MirroredType` and `MirroredElemTypes` match the kind of the data type the mirror is an instance for.
127
127
This allows `Mirrors` to support ADTs of all kinds.
128
128
+ There is no distinct representation type for sums or products (ie. there is no `HList` or `Coproduct` type as in
129
129
Scala 2 versions of shapeless). Instead the collection of child types of a data type is represented by an ordinary,
130
-
possibly parameterized, tuple type. Dotty's metaprogramming facilities can be used to work with these tuple types
130
+
possibly parameterized, tuple type. Scala 3's metaprogramming facilities can be used to work with these tuple types
131
131
as-is, and higher level libraries can be built on top of them.
132
132
+ For both product and sum types, the elements of `MirroredElemTypes` are arranged in definition order (i.e. `Branch[T]`
133
133
precedes `Leaf[T]` in `MirroredElemTypes` for `Tree` because `Branch` is defined before `Leaf` in the source file).
@@ -152,20 +152,20 @@ provider of an ADT with a `derives` clause has to know about the derivation of a
152
152
153
153
Note that `derived` methods may have context `Mirror` parameters indirectly (e.g. by having a context argument which in turn
154
154
has a context `Mirror` parameter, or not at all (e.g. they might use some completely different user-provided mechanism, for
155
-
instance using Dotty macros or runtime reflection). We expect that (direct or indirect) `Mirror` based implementations
155
+
instance using Scala 3 macros or runtime reflection). We expect that (direct or indirect) `Mirror` based implementations
156
156
will be the most common and that is what this document emphasises.
157
157
158
158
Type class authors will most likely use higher level derivation or generic programming libraries to implement
159
159
`derived` methods. An example of how a `derived` method might be implemented using _only_ the low level facilities
160
-
described above and Dotty's general metaprogramming features is provided below. It is not anticipated that type class
160
+
described above and Scala 3's general metaprogramming features is provided below. It is not anticipated that type class
161
161
authors would normally implement a `derived` method in this way, however this walkthrough can be taken as a guide for
162
162
authors of the higher level derivation libraries that we expect typical type class authors will use (for a fully
163
163
worked out example of such a library, see [shapeless 3](https://github.com/milessabin/shapeless/tree/shapeless-3)).
164
164
165
165
#### How to write a type class `derived` method using low level mechanisms
166
166
167
167
The low-level method we will use to implement a type class `derived` method in this example exploits three new
168
-
type-level constructs in Dotty: inline methods, inline matches, and implicit searches via `summonInline` or `summonFrom`. Given this definition of the
168
+
type-level constructs in Scala 3: inline methods, inline matches, and implicit searches via `summonInline` or `summonFrom`. Given this definition of the
169
169
`Eq` type class,
170
170
171
171
@@ -194,7 +194,7 @@ call sites (for instance the compiler generated instance definitions in the comp
194
194
195
195
The body of this method (1) first materializes the `Eq` instances for all the child types of type the instance is
196
196
being derived for. This is either all the branches of a sum type or all the fields of a product type. The
197
-
implementation of `summonAll` is `inline` and uses Dotty's `summonInline` construct to collect the instances as a
197
+
implementation of `summonAll` is `inline` and uses Scala 3's `summonInline` construct to collect the instances as a
198
198
`List`,
199
199
200
200
```scala
@@ -319,7 +319,7 @@ given derived$Eq[T](using eqT: Eq[T]): Eq[Opt[T]] =
319
319
```
320
320
321
321
Alternative approaches can be taken to the way that `derived` methods can be defined. For example, more aggressively
322
-
inlined variants using Dotty macros, whilst being more involved for type class authors to write than the example
322
+
inlined variants using Scala 3 macros, whilst being more involved for type class authors to write than the example
323
323
above, can produce code for type classes like `Eq` which eliminate all the abstraction artefacts (eg. the `Lists` of
324
324
child instances in the above) and generate code which is indistinguishable from what a programmer might write by hand.
325
325
As a third example, using a higher level library such as shapeless the type class author could define an equivalent
@@ -402,8 +402,8 @@ lockstep and it has to assert this conformance in some places using casts. If ge
402
402
written these casts will never fail.
403
403
404
404
As mentioned, however, the compiler-provided mechanism is intentionally very low level and it is anticipated that
405
-
higher level type class derivation and generic programming libraries will build on this and Dotty's other
405
+
higher level type class derivation and generic programming libraries will build on this and Scala 3's other
406
406
metaprogramming facilities to hide these low-level details from type class authors and general users. Type class
407
407
derivation in the style of both shapeless and Magnolia are possible (a prototype of shapeless 3, which combines
408
408
aspects of both shapeless 2 and Magnolia has been developed alongside this language feature) as is a more aggressively
409
-
inlined style, supported by Dotty's new quote/splice macro and inlining facilities.
409
+
inlined style, supported by Scala 3's new quote/splice macro and inlining facilities.
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/motivation.md
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Particular criticisms are:
35
35
```
36
36
one cannot write `currentMap("abc")` since the string "abc" is taken asexplicit argument to the implicit `ctx` parameter. One has to write `currentMap.apply("abc")` instead, which is awkward and irregular. For the same reason, a method definition can only have one implicit parameter section and it must always come last. This restriction not only reduces orthogonality, but also prevents some useful program constructs, such asa method with a regular parameter whose typedepends on an implicit value. Finally, it's also a bit annoying that implicit parameters must have a name, even though in many cases that name is never referenced.
37
37
38
-
5. Implicits pose challenges for tooling. The set of available implicits depends on context, so command completion has to take context into account. This is feasible in an IDE but docs like ScalaDoc that are based static web pages can only provide an approximation. Another problem is that failed implicit searches often give very unspecific error messages, in particular if some deeply recursive implicit search has failed. Note that the Dotty compiler has already made a lot of progress in the error diagnostics area. If a recursive search fails some levels down, it shows what was constructed and what is missing. Also, it suggests imports that can bring missing implicits in scope.
38
+
5. Implicits pose challenges for tooling. The set of available implicits depends on context, so command completion has to take context into account. This is feasible in an IDE but docs like ScalaDoc that are based static web pages can only provide an approximation. Another problem is that failed implicit searches often give very unspecific error messages, in particular if some deeply recursive implicit search has failed. Note that the Scala3 compiler has already made a lot of progress in the error diagnostics area. If a recursive search fails some levels down, it shows what was constructed and what is missing. Also, it suggests imports that can bring missing implicits in scope.
39
39
40
40
None of the shortcomings is fatal, after all implicits are very widely used, and many libraries and applications rely on them. But together, they make code using implicits a lot more cumbersome and less clear than it could be.
41
41
@@ -78,4 +78,3 @@ Could we achieve the same goals by tweaking existing implicits? After having tri
78
78
-Third, even if we would somehow succeed with migration, we still have the problem
79
79
how to teach this. We cannot make existing tutorials go away. Almost all existing tutorials start withimplicit conversions, which will go away; they use normal imports, which will go away, and they explain calls to methods withimplicit parameters by expanding them to plain applications, which will also go away. This means that we'd have
80
80
to add modifications and qualifications to all existing literature and courseware, likely causing more confusion with beginners instead of less. By contrast, with a new syntax there is a clear criterion: Any book or courseware that mentions `implicit` is outdated and should be updated.
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/relationship-implicits.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ asked for.
103
103
104
104
Context bounds are the same in both language versions. They expand to the respective forms of implicit parameters.
105
105
106
-
**Note:** To ease migration, context bounds in Dotty map for a limited time to old-style implicit parameters for which arguments can be passed either in a using clause or
106
+
**Note:** To ease migration, context bounds in Scala 3 map for a limited time to old-style implicit parameters for which arguments can be passed either in a using clause or
107
107
in a normal argument list. Once old-style implicits are deprecated, context bounds
108
108
will map to using clauses instead.
109
109
@@ -141,7 +141,7 @@ Implicit by-name parameters are not supported in Scala 2, but can be emulated to
141
141
142
142
### Implicit Conversions
143
143
144
-
Implicit conversion methods in Scala 2 can be expressed as given instances of the `scala.Conversion` class in Dotty. E.g. instead of
144
+
Implicit conversion methods in Scala 2 can be expressed as given instances of the `scala.Conversion` class in Scala 3. E.g. instead of
@@ -162,18 +162,18 @@ given stringToToken: Conversion[String, Token] = KeyWord(_)
162
162
163
163
### Implicit Classes
164
164
165
-
Implicit classes in Scala 2 are often used to define extension methods, which are directly supported in Dotty. Other uses of implicit classes can be simulated by a pair of a regular class and a given `Conversion` instance.
165
+
Implicit classes in Scala 2 are often used to define extension methods, which are directly supported in Scala 3. Other uses of implicit classes can be simulated by a pair of a regular class and a given `Conversion` instance.
166
166
167
167
### Implicit Values
168
168
169
-
Implicit `val` definitions in Scala 2 can be expressed in Dotty using a regular `val` definition and an alias given.
169
+
Implicit `val` definitions in Scala 2 can be expressed in Scala 3 using a regular `val` definition and an alias given.
170
170
E.g., Scala 2's
171
171
172
172
```scala
173
173
lazyimplicitvalpos:Position= tree.sourcePos
174
174
```
175
175
176
-
can be expressed in Dotty as
176
+
can be expressed in Scala 3 as
177
177
178
178
```scala
179
179
lazyvalpos:Position= tree.sourcePos
@@ -182,13 +182,13 @@ given Position = pos
182
182
183
183
### Abstract Implicits
184
184
185
-
An abstract implicit `val` or `def` in Scala 2 can be expressed in Dotty using a regular abstract definition and an alias given. E.g., Scala 2's
185
+
An abstract implicit `val` or `def` in Scala 2 can be expressed in Scala 3 using a regular abstract definition and an alias given. E.g., Scala 2's
186
186
187
187
```scala
188
188
implicitdefsymDecorator:SymDecorator
189
189
```
190
190
191
-
can be expressed in Dotty as
191
+
can be expressed in Scala 3 as
192
192
193
193
```scala
194
194
defsymDecorator:SymDecorator
@@ -197,7 +197,7 @@ given SymDecorator = symDecorator
197
197
198
198
## Implementation Status and Timeline
199
199
200
-
The Dotty implementation implements both Scala-2's implicits and the new abstractions. In fact, support for Scala-2's implicits is an essential part of the common language subset between 2.13/2.14 and Dotty.
200
+
The Scala 3 implementation implements both Scala-2's implicits and the new abstractions. In fact, support for Scala-2's implicits is an essential part of the common language subset between 2.13/2.14 and Scala 3.
201
201
Migration to the new abstractions will be supported by making automatic rewritings available.
202
202
203
203
Depending on adoption patterns, old style implicits might start to be deprecated in a version following Scala 3.0.
0 commit comments