-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 1 commit
d1c98fd
aa4217f
717b61c
9bb87f0
c3ea17d
331eb09
f14335b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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.
typo: avid -> avoid