Skip to content

Commit 7b5fc1a

Browse files
committed
Better explain scopability
1 parent 5581d74 commit 7b5fc1a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/docs/reference/other-new-features/safe-initialization.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ _stackability_, _monotonicity_ and _scopability_.
114114

115115
Stackability means that objects are initialized in stack order: if the
116116
object `b` is created during the initialization of object `a`, then
117-
`b` should become transitively initialized before or at the same time
117+
all fields of `b` should become initialized before or at the same time
118118
as `a`. Scala enforces this property in syntax by demanding that all
119119
fields are initialized at the end of the primary constructor, except
120120
for the language feature below:
@@ -166,16 +166,16 @@ typestate_ to ensure soundness in the presence of aliasing
166166
[1]. Otherwise, either soundness will be compromised or we have to
167167
disallow the usage of already initialized fields.
168168

169-
Scopability means that given any environment `ρ` (which are the value
170-
bindings for method parameters) and heap `σ` for evaluating an
171-
expression `e`, if the resulting value reaches an object `o`
172-
pre-existent in `σ`, then `o` is reachable from `ρ` in `σ`. Control
173-
effects like coroutines, delimited control, resumable exceptions may
174-
break the property, as they can transport a value upper in the stack
175-
(not in scope) to be reachable from the current scope. Static fields
176-
can also serve as a teleport thus breaks this property. In the
177-
implementation, we need to enforce that teleported values are
178-
transitively initialized.
169+
Scopability means that an expression may only access existing objects via formal
170+
parameters and `this`. More precisely, given any environment `ρ` (which are the
171+
value bindings for method parameters and `this`) and heap `σ` for evaluating an expression
172+
`e`, if the resulting value reaches an object `o` pre-existent in `σ`, then `o`
173+
is reachable from `ρ` in `σ`. Control effects like coroutines, delimited
174+
control, resumable exceptions may break the property, as they can transport a
175+
value upper in the stack (not in scope) to be reachable from the current scope.
176+
Static fields can also serve as a teleport thus breaks this property. In the
177+
implementation, we need to enforce that teleported values are transitively
178+
initialized.
179179

180180
With the established principles and design goals, following rules are imposed:
181181

0 commit comments

Comments
 (0)