Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an alternative spelling: lifetime vs. dependsOn. #8

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions proposals/NNNN-lifetime-dependency.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,18 @@ func f(arg1: borrow ContiguousArray<Int>) -> borrow(arg1) Span<Int>
```
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.

The currently proposed `dependsOn` spelling was chosen to convey the direction of the dependence, as in:

func foo(a: A, b: B) -> dependsOn(a) R

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:

> **lifetime**(*target*: [scoped] *source*)

APIs with ambiguous depenencies would then typically be spelled:

func foo(a: A, b: B) -> lifetime(a) R

### dependsOn(unchecked) to disable lifetime dependence checking

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:
Expand Down