Skip to content

Commit 699d547

Browse files
authored
Merge pull request swiftlang#8 from atrick/lifetime-dependency
Add an alternative spelling: `lifetime` vs. `dependsOn`.
2 parents e814e62 + 9583bd7 commit 699d547

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,18 @@ func f(arg1: borrow ContiguousArray<Int>) -> borrow(arg1) Span<Int>
896896
```
897897
This was changed after we realized that there was in practice almost always a single viable semantic for any given situation, so the additional refinement seemed unnecessary.
898898

899+
The currently proposed `dependsOn` spelling was chosen to convey the direction of the dependence, as in:
900+
901+
func foo(a: A, b: B) -> dependsOn(a) R
902+
903+
This does, however, introduce compound keyword. Alternatively, we could use a simpler `lifetime` keyword, which better matches the feature description. The general syntax would then be:
904+
905+
> **lifetime**(*target*: [scoped] *source*)
906+
907+
APIs with ambiguous depenencies would then typically be spelled:
908+
909+
func foo(a: A, b: B) -> lifetime(a) R
910+
899911
### dependsOn(unchecked) to disable lifetime dependence checking
900912

901913
A `dependsOn(unchecked)` annotation could allow programmers to disable lifetime dependence checking for a function result or argument. For example, the programmer may want to compose a nonescapable result from an immortal value that isn't visible to the compiler:

0 commit comments

Comments
 (0)