You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/NNNN-lifetime-dependency.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,13 +40,13 @@ They cannot guarantee that `buff` will outlive the `array`, which means there is
40
40
Library authors trying to support this kind of code pattern today have a few options, but none are entirely satisfactory:
41
41
42
42
* The client developer can manually insert `withExtendedLifetime` and similar annotations to control the lifetime of specific objects.
43
-
This is awkward and error-prone.
44
-
We would prefer a mechanism where the library author can declare the necessary semantics and have the compiler automatically enforce them.
43
+
This is awkward and error-prone.
44
+
We would prefer a mechanism where the library author can declare the necessary semantics and have the compiler automatically enforce them.
45
45
* The library author can store a back-reference to the container as part of their "pointer" or "slice" object.
46
-
However, this incurs reference counting overhead which sacrifices some of the performance gains that pointer-based designs are generally intended to provide.
47
-
In addition, this approach is not possible in environments that lack support for dynamic allocation.
46
+
However, this incurs reference counting overhead which sacrifices some of the performance gains that pointer-based designs are generally intended to provide.
47
+
In addition, this approach is not possible in environments that lack support for dynamic allocation.
48
48
* The library author can make the pointer information available only within a scoped function, but this is also unsafe, as demonstrated by well-meaning developers who extract the pointer out of such functions using code like that below.
49
-
Even when used correctly, scoped functions can lead to a pyramid of deeply-indented code blocks.
49
+
Even when used correctly, scoped functions can lead to a pyramid of deeply-indented code blocks.
50
50
51
51
```
52
52
// 🛑 The following line of code is dangerous! DO NOT DO THIS!
@@ -90,7 +90,7 @@ Our proposal would allow you to declare an `array.bufferReference()` method as f
0 commit comments