Skip to content

Commit ad1dc9c

Browse files
committed
Fix docs
1 parent 9b0f08e commit ad1dc9c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,15 @@ classes and multiple constructors:
203203

204204
- __Warm[C] { outer = V, ctor, args = Vs }__: A warm object of class `C`, where the immediate outer of `C` is `V`, the constructor is `ctor` and constructor arguments are `Vs`.
205205

206-
The initialization checker checks each class separately. The abstraction `ThisRef`
206+
The initialization checker checks each concrete class separately. The abstraction `ThisRef`
207207
represents the current object under initialization:
208208

209209
- __ThisRef[C]__: The current object of class `C` under initialization.
210210

211-
The initialization state of the current object is stored in the heap as an
211+
The initialization state of the current object is stored in the abstract heap as an
212212
abstract object. The abstract heap also serves as a cache for the field values
213-
of warm objects.
213+
of warm objects. `Warm` and `ThisRef` are "addresses" of the abstract objects stored
214+
in the abstract heap.
214215

215216
Two more abstractions are introduced to support functions and conditional
216217
expressions:
@@ -221,6 +222,23 @@ expressions:
221222

222223
- __Refset(Vs)__: A set of abstract values `Vs`.
223224

225+
A value `v` is _effectively hot_ if any of the following is true:
226+
227+
- `v` is `Hot`.
228+
- `v` is `ThisRef` and all fields of the underlying object are assigned.
229+
- `v` is `Warm[C] { ... }` and
230+
1. `C` does not contain inner classes; and
231+
2. Calling any method on `v` encounters no initialization errors and the method return value is _effectively hot_; and
232+
3. Each field of `v` is _effectively hot_.
233+
- `v` is `Fun(e, V, C)` and calling the function encounters no errors and the
234+
function return value is _effectively hot_.
235+
- The root object (refered by `ThisRef`) is _effectively hot_.
236+
237+
An effectively hot value can be regarded as transitively initialized thus can
238+
be safely leaked via method arguments or as RHS of an reassignment.
239+
The initialization checker tries to promote non-hot values to effectively hot
240+
whenenver possible.
241+
224242
## Rules
225243

226244
With the established principles and design goals, the following rules are imposed:
@@ -241,7 +259,7 @@ With the established principles and design goals, the following rules are impose
241259

242260
Escape of `this` in the constructor is commonly regarded as an anti-pattern.
243261

244-
However, escape of `this` as argument to another constructor is allowed, to support
262+
However, passing non-hot values as argument to another constructor is allowed, to support
245263
creation of cyclic data structures. The checker will ensure that the escaped
246264
non-initialized object is not used, i.e. calling methods or accessing fields
247265
on the escaped object is not allowed.
@@ -282,18 +300,6 @@ With the established principles and design goals, the following rules are impose
282300

283301
9. The scrutinee in a pattern match and the values in return and throw statements must be _effectively hot_.
284302

285-
A value `v` is _effectively hot_ if any of the following is true:
286-
287-
- `v` is `Hot`.
288-
- `v` is `ThisRef` and all fields of the underlying object are assigned.
289-
- `v` is `Warm[C] { outer = V, ctor, args = Vs }` and
290-
1. `C` does not contain inner classes;
291-
2. Calling any method on `v` encounters no initialization errors and the method return value is _effectively hot_;
292-
3. Each field of `v` is _effectively hot_.
293-
- `v` is `Fun(e, V, C)` and calling the function encounters no errors and the
294-
function return value is _effectively hot_.
295-
- `ThisRef` is _effectively hot_.
296-
297303
## Modularity
298304

299305
The analysis takes the primary constructor of concrete classes as entry points.
@@ -306,7 +312,7 @@ tightly coupled. For example, adding a method in the superclass requires
306312
recompiling the child class for checking safe overriding.
307313

308314
Initialization is no exception in this respect. The initialization of an object
309-
essentially invovles close interaction between subclass and superclass. If the
315+
essentially involves close interaction between subclass and superclass. If the
310316
superclass is defined in another project, the crossing of project boundary
311317
cannot be avoided for soundness of the analysis.
312318

@@ -333,5 +339,5 @@ mark some fields as lazy.
333339
## References
334340

335341
1. Fähndrich, M. and Leino, K.R.M., 2003, July. [_Heap monotonic typestates_](https://www.microsoft.com/en-us/research/publication/heap-monotonic-typestate/). In International Workshop on Aliasing, Confinement and Ownership in object-oriented programming (IWACO).
336-
2. Fengyun Liu, Ondřej Lhoták, Aggelos Biboudis, Paolo G. Giarrusso, and Martin Odersky. 2020. [_A type-and-effect system for object initialization_](https://dl.acm.org/doi/10.1145/3428243). OOPSLA, 2020.
337-
3. Fengyun Liu, Ondřej Lhoták, Enze Xing, Nguyen Cao Pham. 2021 [_Safe object initialization, abstractly_](https://dl.acm.org/doi/10.1145/3486610.3486895)
342+
2. Fengyun Liu, Ondřej Lhoták, Aggelos Biboudis, Paolo G. Giarrusso, and Martin Odersky. [_A type-and-effect system for object initialization_](https://dl.acm.org/doi/10.1145/3428243). OOPSLA, 2020.
343+
3. Fengyun Liu, Ondřej Lhoták, Enze Xing, Nguyen Cao Pham. [_Safe object initialization, abstractly_](https://dl.acm.org/doi/10.1145/3486610.3486895). Scala 2021.

0 commit comments

Comments
 (0)