@@ -355,29 +355,29 @@ Finalization models built around calling a method on the
355
355
finalized object (such as Objective-C's :code: `-dealloc `)
356
356
suffer from a number of limitations and problems:
357
357
358
- - Since the method receives a pointer to the object being
359
- deallocated, the implementation must guard against
360
- attempts to resurrect the object. This may complicate
361
- and/or slow down the system's basic reference-management
362
- logic, which tends to be quite important for performance.
363
-
364
- - Since the method receives a pointer to the object being
365
- deallocated, the implementation must leave the object at
366
- least a minimally valid state until the user code is
367
- complete. For example, the instance variables of a
368
- subclass cannot be destroyed until a later phase of
369
- destruction, because a superclass finalizer might invoke
370
- subclass behavior. (This assumes that the dynamic type
371
- of the object does not change during destruction, which
372
- is an alternative that brings its own problems.)
373
-
374
- - Finalization code must be inherent to the object; other
375
- objects cannot request that code be run when the object
376
- is deallocated. For example, an object that registers
377
- itself to observe a certain event source must explicitly
378
- deregister itself in a finalizer; the event source cannot
379
- simply automatically drop the object when it is
380
- deallocated.
358
+ - Since the method receives a pointer to the object being
359
+ deallocated, the implementation must guard against
360
+ attempts to resurrect the object. This may complicate
361
+ and/or slow down the system's basic reference-management
362
+ logic, which tends to be quite important for performance.
363
+
364
+ - Since the method receives a pointer to the object being
365
+ deallocated, the implementation must leave the object at
366
+ least a minimally valid state until the user code is
367
+ complete. For example, the instance variables of a
368
+ subclass cannot be destroyed until a later phase of
369
+ destruction, because a superclass finalizer might invoke
370
+ subclass behavior. (This assumes that the dynamic type
371
+ of the object does not change during destruction, which
372
+ is an alternative that brings its own problems.)
373
+
374
+ - Finalization code must be inherent to the object; other
375
+ objects cannot request that code be run when the object
376
+ is deallocated. For example, an object that registers
377
+ itself to observe a certain event source must explicitly
378
+ deregister itself in a finalizer; the event source cannot
379
+ simply automatically drop the object when it is
380
+ deallocated.
381
381
382
382
Optimization
383
383
------------
@@ -402,15 +402,15 @@ Proposal Overview
402
402
403
403
Looking at these use-cases, there are two main thrusts:
404
404
405
- - There is a general need to set up back references to objects.
406
- These references must be designed for convenient use by non-expert
407
- users.
405
+ - There is a general need to set up back references to objects.
406
+ These references must be designed for convenient use by non-expert
407
+ users.
408
408
409
- - There are a number of more sophisticated use cases which require
410
- notification or interruption of deallocation; these can be used in
411
- the implementation of higher-level abstractions like weak caches.
412
- Here it is reasonable to expect more user expertise, such that
413
- power and flexibility should take priority over ease of use.
409
+ - There are a number of more sophisticated use cases which require
410
+ notification or interruption of deallocation; these can be used in
411
+ the implementation of higher-level abstractions like weak caches.
412
+ Here it is reasonable to expect more user expertise, such that
413
+ power and flexibility should take priority over ease of use.
414
414
415
415
The second set of use cases should addressed by library types working
416
416
on top of basic runtime support.
@@ -439,11 +439,11 @@ variable-like declaration of reference type :code:`T`. For
439
439
type-system purposes, the variables behaves like a normal
440
440
variable of type :code: `Optional<T> `, except:
441
441
442
- - it does not maintain a +1 reference count invariant and
442
+ - it does not maintain a +1 reference count invariant and
443
443
444
- - loading from the variable after the current referent (if present)
445
- has started destruction will result in a :code: `Nothing ` value,
446
- indistinguishable from the normal case.
444
+ - loading from the variable after the current referent (if present)
445
+ has started destruction will result in a :code: `Nothing ` value,
446
+ indistinguishable from the normal case.
447
447
448
448
The semantics are quite similar to weak references in other
449
449
environments (particularly Objective-C) except that the change in
@@ -485,10 +485,10 @@ designed without first having a solid error-handling design.
485
485
type-system purposes, the variable behaves exactly like a normal
486
486
variable of type :code: `T `, except:
487
487
488
- - it does not maintain a +1 reference count invariant and
488
+ - it does not maintain a +1 reference count invariant and
489
489
490
- - loading from the variable after the referent has started
491
- destruction causes an assertion failure.
490
+ - loading from the variable after the referent has started
491
+ destruction causes an assertion failure.
492
492
493
493
This is a refinement of :code: `weak ` focused more narrowly on the case
494
494
of a back reference with relatively tight validity invariants. This
@@ -498,32 +498,32 @@ references; see below.
498
498
This name isn't really optimal. We've considered several different
499
499
candidates:
500
500
501
- - :code: `weak ` is a poor choice because our semantics are very
502
- different from weak references in other environments where it's
503
- valid to access a cleared reference. Plus, we need to expose
504
- those semantics, so the name is claimed.
505
-
506
- - :code: `backref ` is strongly evocative of the major use case in the
507
- static reference graph; this would encourage users to use it for
508
- back references and to consider alternatives for other cases, both
509
- of which I like. The latter also makes the husk-leaking
510
- implementation (see below) more palatable. It also contrasts very
511
- well with :code: `weak `. However, its evocativeness makes it
512
- unwieldy to use for local reference-counting optimizations.
513
-
514
- - :code: `dangling ` is more general than :code: `backref `, but it has
515
- such strong negative associations that it wouldn't be unreasonable
516
- for users to assume that it's unsafe (with all the pursuant
517
- debugging difficulties) based on the name alone. I don't think
518
- we want to discourage a feature that can help users build tighter
519
- invariants on their classes.
520
-
521
- - :code: `unowned ` is somewhat cleaner-looking, and it isn't as tied
522
- to a specific use case, but it does not contrast with :code: `weak `
523
- *at all *; only someone with considerable exposure to weak
524
- references would understand why we named each one the way we did,
525
- and even they are likely to roll their eyes at us. But it's okay
526
- for a working proposal.
501
+ - :code: `weak ` is a poor choice because our semantics are very
502
+ different from weak references in other environments where it's
503
+ valid to access a cleared reference. Plus, we need to expose
504
+ those semantics, so the name is claimed.
505
+
506
+ - :code: `backref ` is strongly evocative of the major use case in the
507
+ static reference graph; this would encourage users to use it for
508
+ back references and to consider alternatives for other cases, both
509
+ of which I like. The latter also makes the husk-leaking
510
+ implementation (see below) more palatable. It also contrasts very
511
+ well with :code: `weak `. However, its evocativeness makes it
512
+ unwieldy to use for local reference-counting optimizations.
513
+
514
+ - :code: `dangling ` is more general than :code: `backref `, but it has
515
+ such strong negative associations that it wouldn't be unreasonable
516
+ for users to assume that it's unsafe (with all the pursuant
517
+ debugging difficulties) based on the name alone. I don't think
518
+ we want to discourage a feature that can help users build tighter
519
+ invariants on their classes.
520
+
521
+ - :code: `unowned ` is somewhat cleaner-looking, and it isn't as tied
522
+ to a specific use case, but it does not contrast with :code: `weak `
523
+ *at all *; only someone with considerable exposure to weak
524
+ references would understand why we named each one the way we did,
525
+ and even they are likely to roll their eyes at us. But it's okay
526
+ for a working proposal.
527
527
528
528
Asserting and Uncheckable
529
529
.........................
@@ -857,19 +857,19 @@ become laborious and redundant, and a different mechanism is called for.
857
857
In the following discussion, a *var-or-member expression * is an
858
858
expression which is semantically constrained to be one of:
859
859
860
- - A reference to a local variable-like declaration from an
861
- enclosing context.
860
+ - A reference to a local variable-like declaration from an
861
+ enclosing context.
862
862
863
- - A member access thereof, possibly recursively.
863
+ - A member access thereof, possibly recursively.
864
864
865
865
Such expressions have two useful traits:
866
866
867
- - They always end in an identifier which on some level meaningfully
868
- identifies the object.
867
+ - They always end in an identifier which on some level meaningfully
868
+ identifies the object.
869
869
870
- - Evaluating them is relatively likely (but not guaranteed) to not
871
- have interesting side effects, and so we feel less bad about
872
- apparently shifting their evaluation around.
870
+ - Evaluating them is relatively likely (but not guaranteed) to not
871
+ have interesting side effects, and so we feel less bad about
872
+ apparently shifting their evaluation around.
873
873
874
874
Decorated Capture References
875
875
----------------------------
0 commit comments