Skip to content

Commit 3055bec

Browse files
committed
Expand alternative syntaxes
1 parent 84521ca commit 3055bec

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,21 +389,19 @@ We propose above using the existing `borrow`/`mutate`/`consume`/`copy` keywords,
389389

390390
We also considered `borrowing`/`mutating`/`consuming`/`copying` but felt that the semantic differences merited using a different form of these words.
391391

392-
Other alternatives considered include:
393-
394-
```
395-
func f(arg1: Array<Int>) -> @dependsOn(arg1) BufferReference<Int>
396-
```
397-
398-
The above syntax states the dependency, but could require elaboration to clarify the type of dependency.
399-
As illustrated by the inference rules above, there is often only one reasonable lifetime dependency type for a particular situation.
400-
But `copy` and “Downgraded dependencies” described below complicate this somewhat.
401-
392+
We could have a single `scoped` annotation that covers the `borrow` and `mutate` semantics described above,
393+
since the semantics are implied by the argument.
394+
Similarly we could collapse `copy` and `consume` to use just `copy` (since they are formally identical).
395+
That would give us two notations rather than the four in our current proposal:
402396
```
403-
func f(arg1: Array<Int>) -> @scoped(arg1) BufferReference<Int>
397+
// `borrow` and `mutate` semantics could share a single annotation:
398+
func f(arg1: borrow Array<Int>) -> scoped(arg1) BufferReference<Int> // Same as `borrow(arg1)`
399+
func f(arg1: inout Array<Int>) -> scoped(arg1) BufferReference<Int> // Same as `mutate(arg1)`
404400
```
405401

406-
Lifetime dependencies are sometimes referred to as “scoped access.” We find this terminology less natural in practice.
402+
This single `scoped` notation would prevent us from eventually supporting the
403+
“Downgraded dependencies” described below.
404+
The `scoped` notation could also be spelled `@scoped` or `@dependsOn`.
407405

408406
#### Implicit argument convention or method mutation modifier
409407

0 commit comments

Comments
 (0)