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/features-classification.md
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ date: February 28, 2019
5
5
author: Martin Odersky
6
6
---
7
7
8
-
This document provides an overview of the features proposed for Scala 3 with the aim to facilitate the discussion what to include and when to include it. It classifies features into seven categories: Essential foundations, simplifications, restrictions, dropped features, changed features, new features, and features oriented towards meta-programming with the aim to replace existing macros.
8
+
This document provides an overview of the features proposed for Scala 3 with the aim to facilitate the discussion what to include and when to include it. It classifies features into seven groups: Essential foundations, simplifications, restrictions, dropped features, changed features, new features, and features oriented towards meta-programming with the aim to replace existing macros.
9
9
10
-
Each feature group contains sections classifying the status (i.e. relative importance to be a part of Scala-3, and relative urgency when to decide this) and the migration cost
10
+
Each feature group contains sections classifying the status (i.e. relative importance to be a part of Scala3, and relative urgency when to decide this) and the migration cost
11
11
of the features in it.
12
12
13
13
The current document reflects the state of things as of end of February, 2019. It will be updated to reflect any future changes in that status.
14
14
15
-
###Essential Foundations
15
+
## Essential Foundations
16
16
17
17
These new features directly model core features of DOT, higher-kinded types, and the [SI calculus for implicit resolution](https://infoscience.epfl.ch/record/229878/files/simplicitly_1.pdf).
18
18
@@ -25,13 +25,13 @@ These new features directly model core features of DOT, higher-kinded types, and
25
25
26
26
**Status: essential**
27
27
28
-
These are essential core features of Scala-3. Without them, Scala-3 would be a completely different language, with different foundations.
28
+
These are essential core features of Scala3. Without them, Scala3 would be a completely different language, with different foundations.
29
29
30
30
**Migration cost: none to low**
31
31
32
32
Since these are additions, there's generally no migration cost for old code. An exception are intersection types which replace compound types with slightly cleaned-up semantics. But few programs would be affected by this change.
33
33
34
-
###Simplifications
34
+
## Simplifications
35
35
36
36
These features replace existing constructs with the aim of making the language safer and simpler to use, and to promote uniformity in code style.
37
37
@@ -42,7 +42,7 @@ These features replace existing constructs with the aim of making the language s
42
42
-[Extension Methods](https://dotty.epfl.ch/docs/reference/contextual/extension-methods.html) replace implicit classes with a clearer and simpler mechanism,
43
43
-[Opaque Type Aliases](https://dotty.epfl.ch/docs/reference/other-new-features/opaques.html) replace most uses
44
44
of value classes while guaranteeing absence of boxing,
-[Vararg patterns](https://dotty.epfl.ch/docs/reference/changed-features/vararg-patterns.html) now use the form `: _*` instead of `@ _*`, mirroring vararg expressions,
replace `new` expressions (under discussion, not implemented),
@@ -51,7 +51,7 @@ These features replace existing constructs with the aim of making the language s
51
51
52
52
With the exception of early initializers and old-style vararg patterns, all superseded features continue to be available in Scala 3.0. The plan is to deprecate and phase them out later.
53
53
54
-
Value classes (superseded by opaque type aliases) are a special case. There are currently no deprecation plans for value classes, since we might want to bring them back in a more general form if they are supported natively by the JVM (as is planned by project Valhalla).
54
+
Value classes (superseded by opaque type aliases) are a special case. There are currently no deprecation plans for value classes, since we might want to bring them back in a more general form if they are supported natively by the JVM as is planned by project Valhalla.
55
55
56
56
**Status: bimodal: now or never / can delay**
57
57
@@ -64,7 +64,7 @@ On the other hand, we need to decide now only about the new features in this lis
64
64
For the next several versions, old features will remain available and deprecation and rewrite techniques can make any migration effort low and gradual.
65
65
66
66
67
-
###Restrictions
67
+
## Restrictions
68
68
69
69
These features are restricted to make the language safer.
70
70
@@ -81,11 +81,11 @@ These are essential restrictions. If we decide to adopt them, we should do it fo
81
81
82
82
**Migration cost: low to high**
83
83
84
-
-low: multiversal equality rules out code that is nonsensical, so any rewrites required by its adoption should be classified as bug fixes.
85
-
-moderate: Restrictions to implicits can be accommodated by straightforward rewriting.
86
-
-high: Unrestricted type projection cannot always rewritten directly since it is unsound in general.
84
+
-_low_: multiversal equality rules out code that is nonsensical, so any rewrites required by its adoption should be classified as bug fixes.
85
+
-_moderate_: Restrictions to implicits can be accommodated by straightforward rewriting.
86
+
-_high_: Unrestricted type projection cannot always rewritten directly since it is unsound in general.
87
87
88
-
###Dropped Features
88
+
## Dropped Features
89
89
90
90
These features are proposed to be dropped without a new feature replacing them. The motivation for dropping these features is to simplify the language and its implementation.
91
91
@@ -120,7 +120,7 @@ Currently implemented features could stay around indefinitely. Updated docs may
120
120
Dropped features require rewrites to avoid their use in programs. These rewrites can sometimes be automatic (e.g. for procedure syntax, symbol literals, auto application)
121
121
and sometimes need to be manual (e.g. class shadowing, auto tupling). Sometimes the rewrites would have to be non-local, affecting use sites as well as definition sites (e.g., in the case of DelayedInit, unless we find a solution).
122
122
123
-
###Changes
123
+
## Changes
124
124
125
125
These features have undergone changes in Scala 3 to make them more regular and useful.
126
126
@@ -139,7 +139,7 @@ The features have been implemented in their new form in Scala 3.0's compiler. Th
139
139
140
140
Only a few programs should require changes, but some necessary changes might be non-local (as in the case of restrictions to implicit scope).
141
141
142
-
###New Features
142
+
## New Features
143
143
144
144
These are additions to the language that make it more powerful or pleasant to use.
145
145
@@ -159,13 +159,13 @@ Enums offer an essential simplification of core features, so they should be adop
159
159
160
160
Being new features, existing code migrates without changes. To be sure, sometimes it would be attractive to rewrite code to make use of the new features in order to increase clarity and conciseness.
161
161
162
-
###Meta Programming
162
+
## Meta Programming
163
163
164
164
The following features together try to put meta programming in Scala on a new basis. So far, meta programming was achieved by a combination of macros and libraries such as Shapeless that were in turn based on some key macros. Current Scala 2 macro mechanisms are a thin veneer on top the current Scala 2 compiler, which makes them fragile and in many cases impossible to port to Scala 3.
165
165
166
166
It's worth noting that macros were never included in the Scala 2 language specification and were so far made available only under an `-experimental` flag. This has not prevented their widespread usage.
167
167
168
-
To enable porting most uses of macros, we propose the advanced language features listed below. These propositions are more provisional than the rest of the proposed language features for Scala 3.0. There might still be some changes until the final release. Stabilizing the feature set needed for meta programming is our first priority.
168
+
To enable porting most uses of macros, we propose the advanced language features listed below. These designs are more provisional than the rest of the proposed language features for Scala 3.0. There might still be some changes until the final release. Stabilizing the feature set needed for meta programming is our first priority.
169
169
170
170
-[Match Types](https://dotty.epfl.ch/docs/reference/new-types/match-types.html) allow computation on types.
171
171
-[Typeclass derivation](https://dotty.epfl.ch/docs/reference/contextual/derivation.html) provides an in-language implementation of the `Gen` macro in Shapeless and other foundational libraries. The new implementation is more robust, efficient and easier to use than the macro.
@@ -183,20 +183,20 @@ We know we need a practical replacement for current macros. The features listed
183
183
184
184
Existing macro libraries will have to be rewritten from the ground up. In many cases the rewritten libraries will turn out to be simpler and more robust than the old ones, but that does not relieve one of the cost of the rewrites. It's currently unclear to what degree users of macro libraries will be affected. We aim to provide sufficient functionality so that core macros can be re-implemented fully, but given the vast feature set of the various macro extensions to Scala 2 it is difficult to arrive at a workable limitation of scope.
185
185
186
-
###Changes to Type Checking and Inference
186
+
## Changes to Type Checking and Inference
187
187
188
-
The Scala-3 compiler uses a new algorithm for type inference, which relies on
188
+
The Scala3 compiler uses a new algorithm for type inference, which relies on
189
189
a general subtype constraint solver. The new algorithm often
190
-
[works better than the old](https://contributors.scala-lang.org/t/better-type-inference-for-scala-send-us-your-problematic-cases/2410), but there are inevitably situations where the results of both algorithms differ, leading to errors diagnosed by Scala 3 for programs that the Scala 2 accepts.
190
+
[works better than the old](https://contributors.scala-lang.org/t/better-type-inference-for-scala-send-us-your-problematic-cases/2410), but there are inevitably situations where the results of both algorithms differ, leading to errors diagnosed by Scala 3 for programs that the Scala 2 compiler accepts.
191
191
192
192
**Status: essential**
193
193
194
-
The new type-checking and inferencing algorithms are the essential core of the new compiler. They cannot be reverted without dropping the whole implementation of Scala 3.
194
+
The new type-checking and inference algorithms are the essential core of the new compiler. They cannot be reverted without dropping the whole implementation of Scala 3.
195
195
196
196
**Migration cost: high**
197
197
198
198
Some existing programs will break and, given the complex nature of type inference, it will not always be clear what change caused the breakage and how to fix it.
199
199
200
-
In our experience macros and changes in type and implicit argument inference together cause the large majority of problems when porting existing code to Scala 3. The latter source of problems could be addressed systematically by a tool that added all inferred types and implicit arguments to a Scala 2 source code file. Most likely such a tool would be implemented as a Scala 2 compiler plugin. The resulting code would have a greatly increased likelihood to compile under Scala 3, but would often be bulky to the point of being unreadable. A second part of the rewriting tool should then selectively and iteratively remove type and implicit annotations that were synthesized by the first part as long as they compile under Scala 3. This second part could be implemented as a program that invokes the Scala 3 compiler `dotc` programmatically.
200
+
In our experience, macros and changes in type and implicit argument inference together cause the large majority of problems encountered when porting existing code to Scala 3. The latter source of problems could be addressed systematically by a tool that added all inferred types and implicit arguments to a Scala 2 source code file. Most likely such a tool would be implemented as a Scala 2 compiler plugin. The resulting code would have a greatly increased likelihood to compile under Scala 3, but would often be bulky to the point of being unreadable. A second part of the rewriting tool should then selectively and iteratively remove type and implicit annotations that were synthesized by the first part as long as they compile under Scala 3. This second part could be implemented as a program that invokes the Scala 3 compiler `dotc` programmatically.
201
201
202
202
Several people have proposed such a tool for some time now. I believe it is time we find the will and the resources to actually implement it.
0 commit comments