feat(pbs): add explicit guest lifecycle hooks
This commit is contained in:
@@ -253,7 +253,7 @@ Rules:
|
||||
- An attribute attaches syntactic metadata to the declaration surface that immediately follows it.
|
||||
- Attributes do not introduce values, types, callables, or modules by themselves.
|
||||
- In v1 core, ordinary user-authored modules MUST reject attributes unless another specification explicitly permits them.
|
||||
- Ordinary userland source MAY use `[Init]` and `[Frame]` only on top-level `fn` declarations.
|
||||
- Ordinary userland source MAY use `[Init]`, `[Frame]`, `[BeforePause]` and `[BeforeResume]` only on top-level `fn` declarations.
|
||||
- Ordinary userland source MAY use `[Doc(markdown = """...""")]` on named API declarations where the static semantics specification permits documentation.
|
||||
- Reserved stdlib/toolchain interface modules MAY use attributes where explicitly allowed by syntax and semantics.
|
||||
- Reserved stdlib/toolchain interface modules MAY additionally use `[InitAllowed]` only on `declare host` method signatures where another specification explicitly permits it.
|
||||
@@ -1218,3 +1218,22 @@ See [PBS generic contracts](../../../compiler/pbs/specs/generic-contracts.md).
|
||||
Struct and module-level free-function declarations and their barrel items accept ordered type parameters. Explicit function applications are reference expressions; calls use existing parentheses/apply. Generic construction supports explicit arguments and contextual diamond/omission. Owner-bound `implements` accepts its own parameter binder and a full applied owner. Independent method parameters, function diamond/inference and polymorphic Fn remain invalid. The owner specification defines exact arity, comparison disambiguation and recovery.
|
||||
|
||||
See [Concrete generic structs and free functions](../../../compiler/pbs/specs/generic-structs-and-free-functions.md).
|
||||
|
||||
|
||||
## Controlled guest lifecycle marker syntax
|
||||
|
||||
`[BeforePause]` and `[BeforeResume]` select optional runtime lifecycle hooks:
|
||||
|
||||
```pbs
|
||||
[BeforePause]
|
||||
fn preparePause() -> void {}
|
||||
[BeforeResume]
|
||||
fn prepareResume() -> void {}
|
||||
```
|
||||
|
||||
These markers accept no arguments and MUST NOT combine with another lifecycle
|
||||
marker (`Init`, `Frame`, `BeforePause`, `BeforeResume`). Existing `[Doc]` metadata
|
||||
may accompany them. Targets MUST be nongeneric top-level userland functions;
|
||||
methods, lambdas, host/interface declarations and other declaration kinds are
|
||||
invalid targets. Function names are arbitrary and do not select runtime roles.
|
||||
PBS exposes no sync statement, lifecycle syscall or termination marker.
|
||||
|
||||
Reference in New Issue
Block a user