Skip to content

Commit 4ce9cb3

Browse files
author
Aggelos Biboudis
authored
Merge 315c3a4 into cf8fead
2 parents cf8fead + 315c3a4 commit 4ce9cb3

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
layout: blog-page
3+
title: Announcing Dotty 0.16.0-RC1 – the Scala Days 2019 Release
4+
author: Aggelos Biboudis
5+
authorImg: /images/aggelos.png
6+
date: 2019-06-11
7+
---
8+
9+
Hello again! Today, we are excited to announce the 16th release of Dotty. The
10+
development of Dotty continues according to our schedule but today, Tuesday June
11+
the 11th, we are electrified as it is the first day of [Scala Days 2019](https://scaladays.org/)
12+
which marks the *10th* anniversary of Scala Days.
13+
With this release we are getting closer to the _envelop_ of the new features
14+
that Dotty plans to offer.
15+
16+
![]({{ site.baseurl }}/images/others/scala-days-logo.png "Scala Days 2019")
17+
18+
This release serves as a technology preview that demonstrates new
19+
language features and the compiler supporting them.
20+
21+
Dotty is the project name for technologies that are being considered for
22+
inclusion in Scala 3. Scala has pioneered the fusion of object-oriented and
23+
functional programming in a typed setting. Scala 3 will be a big step towards
24+
realising the full potential of these ideas. Its main objectives are to
25+
26+
- become more opinionated by promoting programming idioms we found to work well,
27+
- simplify where possible,
28+
- eliminate inconsistencies and surprising behaviours,
29+
- build on strong foundations to ensure the design hangs together well,
30+
- consolidate language constructs to improve the language’s consistency, safety, ergonomics, and
31+
performance.
32+
33+
You can learn more about Dotty on our [website](https://dotty.epfl.ch).
34+
35+
<!--more-->
36+
37+
This is our 16th scheduled release according to our
38+
[6-week release schedule](https://dotty.epfl.ch/docs/contributing/release.html).
39+
40+
# What’s new in the 0.16.0-RC1 technology preview?
41+
42+
<!-- https://github.com/lampepfl/dotty/pulls?q=is%3Apr+closed%3A%3E2019-05-23+is%3Aclosed+sort%3Acomments-desc -->
43+
44+
## Syntax Change: Type Lambdas
45+
46+
We reconsider the syntax of type lambdas in an effort to provide an improved
47+
visual cue for two categories of types: types that relate to normal function
48+
types and types that operate on a higher level. The _fat_ arrow `=>` definitely
49+
relates to the first, while we reserve now `->` to mean _pure function_ in the
50+
future. As a result, we disengage `=>` from type lambdas, which are now
51+
represented by `=>>`. As a result a function from types to types is written as
52+
`[X] =>> F[X]`.
53+
54+
For those who are interested in the discussions,
55+
[#6558](https://github.com/lampepfl/dotty/pull/6558) introduced the new syntax.
56+
57+
## Syntax Change: Wildcard Arguments in Types
58+
59+
The syntax of wildcard arguments in types has changed from `_` to `?`. Example:
60+
61+
```scala
62+
List[?]
63+
Map[? <: AnyRef, ? >: Null]
64+
```
65+
66+
Again, in an effort to fine-tune our syntax we put two features, from the world
67+
of terms and types, side-by-side and drew parallels at the syntactic level.
68+
Consequently, as `f(_)` is a shorthand for the lambda `x => f(x)` and as we plan
69+
ahead for making `C[_]` to be a shorthand for the type lambda `[X] =>> C[X]` in
70+
the future we pick `?` as a replacement syntax for wildcard types, since it
71+
aligns with Java's syntax.
72+
73+
For more information please read our documentation on
74+
[Wildcards](https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html).
75+
76+
## Polymorphic function types
77+
78+
We add preliminary support for _polymorphic function types_. Nowadays, when we
79+
want to write a universally quantified function over elements of lists of type
80+
`T` we write e.g., `List[T] => List[(T, T)]` where `T` is bound at an enclosing
81+
definition. With polymorphic function types (PFT hereafter) we can quantify the
82+
parametric type locally. For example:
83+
84+
```scala
85+
[T <: AnyVal] => List[T] => List[(T, T)]
86+
```
87+
88+
As you notice, this gives us the ability to impose restrictions on the type
89+
variable `T` locally. Assume, you have an identity function with `type id = T => T`.
90+
By writing it as `type id = [T] => T => T` we abstract further the concept
91+
of a _polymorphic function_ and make it a *true* _family of functions_.
92+
93+
The code below (correctly) fails to type check because `T` needs to be bounded
94+
in the enclosing class:
95+
96+
```scala
97+
val id: T => T = t => t
98+
println(s"${id(1)} , ${id(7.0d)}")
99+
```
100+
101+
With PFTs we can now achieve what we want:
102+
103+
```scala
104+
val id = [T] => (t: T) => t
105+
println(s"${id(1)} , ${id(7.0d)}")
106+
```
107+
108+
For those who are interested in the discussions and more test cases,
109+
[#4672](https://github.com/lampepfl/dotty/pull/4672/) introduced PFTs.
110+
111+
## lazy vals are now thread-safe by default
112+
113+
Previously thread-safety was required using `@volatile` but that would not be
114+
consistent with Scala 2. The old behavior of non-volatile lazy vals can be
115+
recovered by using the newly-introduced `@threadUnsafe`.
116+
117+
For more information please read our documentation on the
118+
[threadUnsafe annotation](https://dotty.epfl.ch/docs/reference/other-new-features/threadUnsafe-annotation.html).
119+
120+
## Introducing `for` clauses for importing implied imports by type
121+
122+
Since implied instances can be anonymous it is not always practical to import
123+
them by their name, and wildcard imports are typically used instead. By-type
124+
imports provide a more specific alternative to wildcard imports, which makes it
125+
clearer what is imported. Example:
126+
127+
```scala
128+
import implied A.{for TC}
129+
```
130+
131+
This imports any implied instance in `A` that has a type which conforms tp `TC`.
132+
There can be several bounding types following a `for` and bounding types can
133+
contain wildcards.
134+
For instance, assuming the object
135+
136+
```scala
137+
object Instances {
138+
implied intOrd for Ordering[Int]
139+
implied [T: Ordering] listOrd for Ordering[List[T]]
140+
implied ec for ExecutionContext = ...
141+
implied im for Monoid[Int]
142+
}
143+
```
144+
the import
145+
```
146+
import implied Instances.{for Ordering[_], ExecutionContext}
147+
```
148+
would import the `intOrd`, `listOrd`, and `ec` instances but leave out the `im`
149+
instance, since it fits none of the specified bounds.
150+
151+
# Let us know what you think!
152+
153+
If you have questions or any sort of feedback, feel free to send us a message on our
154+
[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please
155+
[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new).
156+
157+
## Contributing
158+
159+
Thank you to all the contributors who made this release possible!
160+
161+
According to `git shortlog -sn --no-merges 0.15.0-RC1..0.16.0-RC1` these are:
162+
163+
```
164+
165+
```
166+
167+
If you want to get your hands dirty and contribute to Dotty, now is a good time to get involved!
168+
Head to our [Getting Started page for new contributors](https://dotty.epfl.ch/docs/contributing/getting-started.html),
169+
and have a look at some of the [good first issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%3Anovice).
170+
They make perfect entry points into hacking on the compiler.
171+
172+
We are looking forward to having you join the team of contributors.
173+
174+
## Library authors: Join our community build
175+
176+
Dotty now has a set of widely-used community libraries that are built against every nightly Dotty
177+
snapshot. Currently this includes ScalaPB, algebra, scalatest, scopt and squants.
178+
Join our [community build](https://github.com/lampepfl/dotty-community-build)
179+
to make sure that our regression suite includes your library.
180+
181+
[Scastie]: https://scastie.scala-lang.org/?target=dotty
182+
183+
[@odersky]: https://github.com/odersky
184+
[@DarkDimius]: https://github.com/DarkDimius
185+
[@smarter]: https://github.com/smarter
186+
[@felixmulder]: https://github.com/felixmulder
187+
[@nicolasstucki]: https://github.com/nicolasstucki
188+
[@liufengyun]: https://github.com/liufengyun
189+
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
190+
[@biboudis]: https://github.com/biboudis
191+
[@allanrenucci]: https://github.com/allanrenucci
192+
[@Blaisorblade]: https://github.com/Blaisorblade
193+
[@Duhemm]: https://github.com/Duhemm
194+
[@AleksanderBG]: https://github.com/AleksanderBG
195+
[@milessabin]: https://github.com/milessabin
196+
[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk
340 KB
Loading

0 commit comments

Comments
 (0)