Skip to content

Commit d9aa90b

Browse files
authored
Merge pull request #3 from atrick/lifetime-dependency
Update and cleanup the grammar.
2 parents c6ede5d + def2c82 commit d9aa90b

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -504,29 +504,32 @@ The compiler must issue a diagnostic if any of the above cannot be satisfied.
504504

505505
### Grammar
506506

507+
This new syntax adds an optional `dependsOn(...)` lifetime modifier just before the return type and parameter types. This modifies *function-result* in the Swift grammar as follows:
507508

508-
TODO:
509-
510-
* dependent parameters
511-
* 'immortal' keyword
512-
513-
This new syntax adds an optional lifetime modifier just before the return type.
514-
This modifies *function-result* in the Swift grammar as follows:
515-
516-
>
517509
> *function-signature**parameter-clause* **`async`***?* **`throws`***?* *function-result**?* \
518510
> *function-signature**parameter-clause* **`async`***?* **`rethrows`** *function-result**?* \
519511
> *function-result***`->`** *attributes?* *lifetime-modifiers?* *type* \
520-
> *lifetime-modifiers***`->`** *lifetime-modifier* *lifetime-modifiers?* \
521-
> *lifetime-modifier***`->`** **`dependsOn`** **`(`** *lifetime-dependent* **`)`** \
522-
> *lifetime-dependent***`->`** **`self`** | *local-parameter-name* | **`scoped self`** | **`scoped`** *local-parameter-name*
512+
> *lifetime-modifiers**lifetime-modifier* *lifetime-modifiers?* \
513+
> *lifetime-modifier***`dependsOn`** **`(`** *lifetime-dependent-list* **`)`** \
514+
> *lifetime-dependence-list**lifetime-dependent* | *lifetime-dependence-source* **`,`** *lifetime-dependent-list*
515+
> *lifetime-dependence-source***`self`** | *local-parameter-name* | **`scoped self`** | **`scoped`** *local-parameter-name* | **`immortal`**
516+
>
517+
> *parameter-type-annotation* → : *attributes?* *lifetime-modifiers?* *parameter-modifier*? *type*
518+
>
519+
520+
The new syntax also adds an optional `selfDependsOn(...)` lifetime modifier before function declarations. This extends *declaration-modifier* as follows:
521+
522+
>
523+
> *declaration-modifier**self-lifetime-modifier* \
524+
> *self-lifetime-modifier***`selfDependsOn`** **`(`** *lifetime-dependent-list* **`)`**
523525
>
524526
525527
The *lifetime-dependent* argument to the lifetime modifier is one of the following:
526528

527529
* *local-parameter-name*: the local name of one of the function parameters, or
528530
* the token **`self`**, or
529-
* either of the above preceded by the **`scoped`** keyword
531+
* either of the above preceded by the **`scoped`** keyword, or
532+
* the token **`immortal`**
530533

531534
This modifier creates a lifetime dependency with the return value used as the dependent value.
532535
The return value must be nonescapable.

0 commit comments

Comments
 (0)