Skip to content

Commit d1c98fd

Browse files
committed
Add changes section
1 parent d11d20f commit d1c98fd

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

docs/docs/reference/adts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The changes are specified below as deltas with respect to the Scala syntax given
108108
EnumDef ::= id ClassConstr [`extends' [ConstrApps]]
109109
[nl] `{’ EnumCaseStat {semi EnumCaseStat} `}’
110110

111-
2. Cases of enums are defined as follows:
111+
2. Cases of enums are defined as follows:
112112

113113
EnumCaseStat ::= {Annotation [nl]} {Modifier} EnumCase
114114
EnumCase ::= `case' (EnumClassDef | ObjectDef | ids)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: doc-page
3+
title: Changed: Lazy Vals and @volatile
4+
---
5+
6+
Lazy val initialization no longer guarantees safe publishing. This change was done
7+
to avid the performance overhead of thread synchonization because many lazy vals are only used in a single-threaded context.
8+
9+
To get back safe publishing you need to annotate a lazy val with `@volatile`. In
10+
11+
@volatile lazy val x = expr
12+
13+
it is guaranteed that readers of a lazy val will see the value of `x`
14+
once it is assigned.
15+
16+
The [ScalaFix](https://scalacenter.github.io/scalafix/) rewrite tool
17+
as well as Dotty's own `-migration` option will rewrite all normal
18+
lazy vals to volatile ones in order to keep their semantics compatible
19+
with current Scala's.

docs/sidebar.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ sidebar:
3535
url: docs/reference/auto-parameter-tupling.html
3636
- title: Named Type Arguments
3737
url: docs/reference/named-typeargs.html
38+
- title: Changed Features
39+
subsection:
40+
- title: Volatile Lazy Vals
41+
url: docs/reference/changed/lazy-vals.md
42+
- title: Structural Types
43+
url: docs/reference/changed/structural-types.md
3844
- title: Dropped Features
3945
subsection:
4046
- title: DelayedInit

0 commit comments

Comments
 (0)