-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add section on dropping DelayedInit #2583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2cd9ab6
Add section on dropping DelayedInit
odersky 88b0f00
Move delayedInit.md to dropped subdirectory
odersky 15e4e13
Add section for dropped feature "macros"
odersky fff1ca2
Fix typo and add test
odersky 28f2f23
Add sections on dropped features
odersky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Class Shadowing | ||
--- | ||
|
||
Scala so far allowed patterns like this: | ||
|
||
class Base { | ||
class Ops { ... } | ||
} | ||
|
||
class Sub extends Base { | ||
class Ops { ... } | ||
} | ||
|
||
Dotty rejects this with the error message: | ||
|
||
6 | class Ops { } | ||
| ^ | ||
|class Ops cannot have the same name as class Ops in class Base -- class definitions cannot be overridden | ||
|
||
The issue is that the two `Ops` classes _look_ like one overrides the | ||
other, but classes in Scala cannot be overridden. To keep things clean | ||
(and its internal operations conistent) the Dotty compiler forces you | ||
to rename the inner classes so that their names are different. | ||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Delayedinit | ||
--- | ||
|
||
The special handling of the `DelayedInit` trait is no longer | ||
supported. | ||
|
||
One consequence is that the `App` class, which used `DelayedInit` is | ||
now partially broken. You can still use `App` for an easy and concise | ||
way to set up a main program. Example: | ||
|
||
object HelloWorld extends App { | ||
println("Hello, world!") | ||
} | ||
|
||
However, the code is now run in the initializer of the object, which on | ||
some JVM's means that it will only be interpreted. So, better not use it | ||
for benchmarking! Also, if you want to access the command line arguments, | ||
you need to use an explicit `main` method for that. | ||
|
||
object Hello { | ||
def main(args: Array[String]) = | ||
println(s"Hello, ${args(0)}") | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Early Initializers | ||
--- | ||
|
||
Early initializers of the form | ||
|
||
class C extends { ... } with SuperClass ... | ||
|
||
have been dropped. They were rarely used, and mostly to compensate for the lack of | ||
[trait parameters](../trait-parameters.md), which are now directly supported in Dotty. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Existential Types | ||
--- | ||
|
||
Existential types using `forSome` have been dropped. The reasons for dropping them were: | ||
|
||
- Existential types violate a type soundness principle on which DOT | ||
and Dotty are constructed. That principle says that every the | ||
prefix (`p`, respectvely `S`) of a type selection `p.T` or `S#T` | ||
must either come from a value constructed at runtime or refer to a | ||
type that is known to have only good bounds. | ||
|
||
- Existential types create many difficult feature interactions | ||
with other Scala constructs. | ||
|
||
- Existential types have large overlap with path-dependent types, | ||
so the gain of having them is relatively minor. | ||
|
||
Existential types that can be expressed using only wildcards (but not | ||
`forSome`) are still supported, but are treated as refined types. | ||
For instance, the type | ||
|
||
Map[_ <: AnyRef, Int] | ||
|
||
is treated as the type `Map`, where the first type parameter | ||
is upper-bounded by `AnyRef` and the second type parameter is an alias | ||
of `Int`. | ||
|
||
When reading classfiles compiled with _scalac_, Dotty will do a best | ||
effort to approximate existential types with its own types. It will | ||
issue a warning is a precise emulation is not possible. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Limit 22 | ||
--- | ||
|
||
The limit of 22 for the maximal number of parameters of function types | ||
has been dropped. Functions can now have an arbitrary number of | ||
parameters. Functions beyond Function22 are represented with a new trait | ||
`scala.FunctionXXL`. | ||
|
||
The limit of 22 for the size of tuples is about to be dropped. Tuples | ||
will in the future be represented by an HList-like structure which can | ||
be arbitrarily large. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Macros | ||
--- | ||
|
||
The previous, experimental macro system has been dropped. Instead, | ||
there is a cleaner, more restricted system based on two complementary | ||
concepts: `inline` and `meta`. | ||
|
||
`inline` has been [implemented](../inline.md) in Dotty. | ||
|
||
`meta` is worked on in the separate [Scalameta](http://scalameta.org) project | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: Procedure Syntax | ||
--- | ||
|
||
Procedure syntax | ||
|
||
def f() { ... } | ||
|
||
has been dropped. You need to write one of the following instead: | ||
|
||
def f() = { ... } | ||
def f(): Unit = { ... } | ||
|
||
Dotty will accept the old syntax under the `-language:Scala2` option. | ||
If the `-migration` option is set, it can even rewrite old syntax to new. | ||
The [ScalaFix](https://scalacenter.github.io/scalafix/) tool also | ||
can rewrite procedure syntax to make it Dotty-compatible. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: General Type Projection | ||
--- | ||
|
||
Scala so far allowed general type projection `T#A` where `T` is an arbitrary type | ||
and `A` names a type member of `T`. | ||
|
||
Dotty allows this only if `T` is a class type. The change was made because | ||
unrestricted type projection is [unsound](https://github.com/lampepfl/dotty/issues/1050). | ||
|
||
The restriction rule out the [type-level encoding of compbinator | ||
calculus](https://michid.wordpress.com/2010/01/29/scala-type-level-encoding-of-the-ski-calculus/). It also rules out the previous encodings of type | ||
lambdas using structural types with projection as application. Type | ||
lambdas are now [directly supported](../type-lambdas.md) in Dotty. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: doc-page | ||
title: Dropped: XML Literals | ||
--- | ||
|
||
XML Literals are still supported, but will be dropped in the near future, to | ||
be replaced with XML string interpolation | ||
|
||
xml""" ... """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Base { | ||
class Ops { } | ||
} | ||
|
||
class Sub extends Base { | ||
class Ops { } // error: cannot override | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object Test extends App { | ||
println("Hello World: ") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/s/compbinator/combinator