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/overview.md
+26-23Lines changed: 26 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The new features all address one or more of four major concerns:
12
12
-[Performance](performance)
13
13
14
14
Scala 3 also drops a number of features that were used rarely, or where experience showed
15
-
that they tended to cause problems in codebases. These are [listed in a separate section](./dropped).
15
+
that they tended to cause problems in codebases. These are listed separately in the [Dropped Features](http://dotty.epfl.ch/docs) section.
16
16
17
17
Not included in this overview are changes to meta programming and generic programming. So far these have relied on a macro system that had experimental status (`scala.reflect` macros. This macro system will be replaced with a different solution. The current state of the design will be described elsewhere.
18
18
@@ -21,52 +21,57 @@ Not included in this overview are changes to meta programming and generic progra
21
21
22
22
Constructs that make the language more consistent internally, and consistent with its foundations. Constructs that admit useful laws of reasoning.
Multiversal equality is an opt in way to check that comparisons using `==` and
67
72
`!=` only apply to compatible types. It thus closes the biggest remaining hurdle
68
73
to type-based refactoring. Normally, one would wish that one could change the type
69
-
of some value or operation in a large codebase, fix all type errors, and obtain
74
+
of some value or operation in a large code base, fix all type errors, and obtain
70
75
at the end a working program. But universal equality `==` works for all types.
71
76
So what should conceptually be a type error would not be reported and
72
77
runtime behavior would change instead. Multiversal equality closes that loophole.
@@ -88,47 +93,45 @@ reliability of refactorings.
88
93
will be defined by the language, others can be added by libraries. Initially, the language
89
94
will likely only cover exceptions as effect capabilities, but it can be extended later
90
95
to mutations and possibly other effects. To ensure backwards compatibility, all effect
91
-
capabilities are initially available in `Predef`. Unimporting effect capabilities from
96
+
capabilities are initially available in `Predef`. Un-importing effect capabilities from
92
97
`Predef` will enable stricter effect checking, and provide stronger guarantees of purity.
93
98
94
99
<aname="ergonomics"></a>
95
100
## Ergonomics
96
101
97
102
Constructs that make common programming patterns more concise and readable.
98
103
99
-
- Enums `enum Color { case Red, Green, Blue }`
104
+
-[Enums](http://dotty.epfl.ch/docs/reference/enums/enums.html)`enum Color { case Red, Green, Blue }`
100
105
101
106
Enums give a simple way to express a type with a finite set of named values. They
102
107
are found in most languages. The previous encodings of enums in Scala were all had
103
108
problems that prevented universal adoption. The new native `enum` construct in Scala
104
-
is quite flexile; among others it gives a more concise way to write algebraic data types,
109
+
is quite flexible; among others it gives a more concise way to write [algebraic data types](http://dotty.epfl.ch/docs/reference/enums/adts.html),
105
110
which would otherwise be expressed by a sealed base trait with case classes as alternatives.
106
-
Scala enums will interop with en the host platform. They support multiversal equality
111
+
Scala enums will interoperate with the host platform. They support multiversal equality
107
112
out of the box, i.e. an enum can only be compared to values of the same enum type.
108
113
109
114
- Extension clauses `extension StringOps for String { ... }`
110
115
111
-
(Pending) Extension clauses allow to define extension methods and late implementations
116
+
([Pending](https://github.com/lampepfl/dotty/pull/4114)) Extension clauses allow to define extension methods and late implementations
112
117
of traits via instance declarations. They are more readable and convey intent better
113
118
than the previous encodings of these features through implicit classes and value classes.
114
119
Extensions will replace implicit classes. Extensions and opaque types together can
115
-
replace almost all usages of value classes.
120
+
replace almost all usages of value classes. Value classes are kept around for the
121
+
time being since there might be a new good use case for them in the future if the host platform supports "structs" or some other way to express multi-field value classes.
116
122
117
123
<aname="performance"></a>
118
124
## Performance
119
125
120
126
- Opaque Type Aliases `opaque type A = T`
121
127
122
-
(Pending) An opaque alias allows to define a new type `A` in terms of an existing type `T`. Unlike the previous modeling using value classes, opqaue types guarantee no boxing.
123
-
Opaque types are described in detail in [SIP 35](https://docs.scala-lang.org/sips/opaque-types.html).
128
+
([Pending](https://github.com/lampepfl/dotty/pull/4028)) An opaque alias defines a new type `A` in terms of an existing type `T`. Unlike the previous modeling using value classes, opaque types never box. Opaque types are described in detail in [SIP 35](https://docs.scala-lang.org/sips/opaque-types.html).
0 commit comments