Skip to content

Add docs on changed features #2592

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 7 commits into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/reference/adts.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The changes are specified below as deltas with respect to the Scala syntax given
EnumDef ::= id ClassConstr [`extends' [ConstrApps]]
[nl] `{’ EnumCaseStat {semi EnumCaseStat} `}’

2. Cases of enums are defined as follows:
2. Cases of enums are defined as follows:

EnumCaseStat ::= {Annotation [nl]} {Modifier} EnumCase
EnumCase ::= `case' (EnumClassDef | ObjectDef | ids)
Expand Down
19 changes: 19 additions & 0 deletions docs/docs/reference/changed/lazy-vals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
layout: doc-page
title: Changed: Lazy Vals and @volatile
---

Lazy val initialization no longer guarantees safe publishing. This change was done
to avid the performance overhead of thread synchonization because many lazy vals are only used in a single-threaded context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: avid -> avoid


To get back safe publishing you need to annotate a lazy val with `@volatile`. In

@volatile lazy val x = expr

it is guaranteed that readers of a lazy val will see the value of `x`
once it is assigned.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the difference in behavior between volatile and non-volatile lazy vals?


The [ScalaFix](https://scalacenter.github.io/scalafix/) rewrite tool
as well as Dotty's own `-migration` option will rewrite all normal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-migration is only for migration warnings, to get dotty to rewrite stuff you need -language:Scala2 -rewrite.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be best to not mention the dotty internal rewrite mechanism until we know what we want to do with it.

lazy vals to volatile ones in order to keep their semantics compatible
with current Scala's.
6 changes: 6 additions & 0 deletions docs/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ sidebar:
url: docs/reference/auto-parameter-tupling.html
- title: Named Type Arguments
url: docs/reference/named-typeargs.html
- title: Changed Features
subsection:
- title: Volatile Lazy Vals
url: docs/reference/changed/lazy-vals.md
- title: Structural Types
url: docs/reference/changed/structural-types.md
- title: Dropped Features
subsection:
- title: DelayedInit
Expand Down