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-non-escapable.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,13 +163,13 @@ func f() {
163
163
}
164
164
```
165
165
166
-
#### Constraints on nonescapable arguments
166
+
#### Constraints on nonescapable parameters
167
167
168
-
A value of nonescapable type received as an argument is subject to the same constraints as any other local variable.
169
-
In particular, a nonescapable `consuming`argument (and all direct copies thereof) must actually be destroyed during the execution of the function.
170
-
This is in contrast to an _escapable_`consuming`argument which can be disposed of by being returned or stored to an instance property or global variable.
168
+
A value of nonescapable type received as an parameter is subject to the same constraints as any other local variable.
169
+
In particular, a nonescapable `consuming`parameter (and all direct copies thereof) must actually be destroyed during the execution of the function.
170
+
This is in contrast to an _escapable_`consuming`parameter which can be disposed of by being returned or stored to an instance property or global variable.
171
171
172
-
#### Values that contain nonescapable values must be nonescapable
172
+
#### Types that contain nonescapable values must be nonescapable
173
173
174
174
Stored struct properties and enum payloads can have nonescapable types if the surrounding type is itself nonescapable.
175
175
Equivalently, an escapable struct or enum can only contain escapable values.
@@ -206,7 +206,7 @@ func f() -> NotEscapable { // 🛑 Cannot return a nonescapable type
206
206
}
207
207
```
208
208
209
-
A separate proposal describes “lifetime dependency annotations” that can relax this requirement by tying the lifetime of the returned value to the lifetime of some other object, either an argument to the function or `self`in the case of a method or computed property returning a nonescapable type.
209
+
A separate proposal describes “lifetime dependency annotations” that can relax this requirement by tying the lifetime of the returned value to the lifetime of another binding. The other binding can be a parameter of a function returning a vaule of a nonescapable type, or con be `self`for a method or computed property returning a value of a nonescapable type.
210
210
In particular, struct and enum initializers (which build a new value and return it to the caller) cannot be written without some mechanism similar to that outlined in our companion proposal.
211
211
212
212
#### Globals and static variables cannot be nonescapable
@@ -223,7 +223,7 @@ Returning a nonescapable value from a closure requires explicit lifetime depende
223
223
224
224
#### Nonescapable values and concurrency
225
225
226
-
All of the requirements on use of nonescapable values as function arguments and return values also apply to async functions, including those invoked via `async let`.
226
+
All of the requirements on use of nonescapable values as function parameters and return values also apply to async functions, including those invoked via `async let`.
227
227
228
228
The closures used in `Task.init`, `Task.detached`, or `TaskGroup.addTask` are escaping closures and therefore cannot capture nonescapable values.
0 commit comments