Skip to content

Commit d7f4917

Browse files
committed
Switch @feature to @unstable, add an optional 'feature' field to @SInCE instead of allowing both
1 parent e0e2cf9 commit d7f4917

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

design/mvp/WIT.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -945,35 +945,37 @@ interface foo {
945945
@since(version = "0.2.1")
946946
b: func();
947947
948-
@since(version = "0.2.2")
949-
@feature(name = "fancy-foo")
948+
@since(version = "0.2.2", feature = "fancy-foo")
950949
c: func();
951950
952-
@feature(name = "fancier-foo")
951+
@unstable(feature = "fancier-foo")
953952
d: func();
954953
}
955954
```
956955
The `@since` gate indicates that `b` and `c` were added as part of the `0.2.1`
957956
and `0.2.2` releases, resp. Thus, when building a component targeting, e.g.,
958957
`0.2.1`, `b` can be used, but `c` cannot. An important expectation set by the
959-
`@since` gate is that, once applied to an item, the item is never modified
958+
`@since` gate is that, once applied to an item, the item is not modified
960959
incompatibly going forward (according to general semantic versioning rules).
961960

962-
In contrast, the lone `@feature` gate on `d` indicates that `d` is part of the
961+
In contrast, the `@unstable` gate on `d` indicates that `d` is part of the
963962
`fancier-foo` feature that is still under active development and thus `d` may
964963
change type or be removed at any time. An important expectation set by the
965-
`@feature` gate is that toolchains will not expose `@feature`-only-gated items
966-
by default unless explicitly opted-into by the developer.
964+
`@unstable` gate is that toolchains will not expose `@unstable` features by
965+
default unless explicitly opted-into by the developer.
967966

968967
Together, these gates support a development flow in which new features start
969-
with a `@feature` gate while the details are still being hashed out. Then, once
970-
the feature is stable (and, in a WASI context, voted upon), the `@since` gate
971-
can be added. To enable a smooth transition, both gates can be present at the
972-
same time, exposing the feature by when the target version is greater-or-equal.
973-
After a suitable transition period (during which producer toolchains bump their
974-
default target versions to enable the feature by default), the `@feature` gate
975-
can then be removed. Thus, in the above example, the `fancy-foo` feature gate
976-
could be removed from `c` once `0.2.2` is the default target version.
968+
with an `@unstable` gate while the details are still being hashed out. Then,
969+
once the feature is stable (and, in a WASI context, voted upon), the
970+
`@unstable` gate is switched to a `@since` gate. To enable a smooth transition
971+
(during which producer toolchains are targeting a version earlier than the
972+
`@since`-specified `version`), the `@since` gate contains an optional `feature`
973+
field that, when present, says to enable the feature when *either* the target
974+
version is greator-or-equal *or* the feature name is explicitly enabled by the
975+
developer. Thus, `c` is enabled if the version is `0.2.2` or newer or the
976+
`fancy-foo` feature is explicitly enabled by the developer. The `feature` field
977+
can be removed once producer toolchains have updated their default version to
978+
enable the feature by default.
977979

978980
Specifically interfaces have the structure:
979981

@@ -984,9 +986,11 @@ interface-item ::= 'interface' id '{' interface-items* '}'
984986
985987
interface-items ::= gate interface-definition
986988
987-
gate ::= since-gate? feature-gate?
988-
since-gate ::= '@since' '(' 'version' '=' '"' <valid semver> '"' ')'
989-
feature-gate ::= '@feature' '(' 'name' '=' '"' id '"' ')'
989+
gate ::= unstable-gate
990+
| since-gate
991+
unstable-gate ::= '@unstable' '(' feature-field ')'
992+
feature-field ::= 'feature' '=' '"' id '"'
993+
since-gate ::= '@since' '(' 'version' '=' '"' <valid semver> '"' ( ',' feature-field )? ')'
990994
991995
interface-definition ::= typedef-item
992996
| use-item
@@ -1672,12 +1676,13 @@ standalone interface definitions (such `wasi:http/handler`) are no longer in a
16721676
`use`s are replaced by direct aliases to preceding type imports as determined
16731677
by the WIT resolution process.
16741678

1675-
Unlike most other WIT constructs, the `@feature` and `@version` gates are not
1676-
represented in the component binary. Instead, these are considered "macro"
1677-
constructs that take the place of maintaining two copies of a single WIT document.
1678-
In particular, when encoding a collection of WIT documents into a binary, a target
1679-
version and set of feature names is supplied and determines whether individual
1680-
gated items are included or not.
1679+
Unlike most other WIT constructs, the `@since` and `@unstable` gates are not
1680+
represented in the component binary. Instead, they are considered "macro"
1681+
constructs that take the place of maintaining two copies of a single WIT
1682+
document. In particular, when encoding a collection of WIT documents into a
1683+
binary, the target version and set of explicitly-enabled feature names
1684+
determine whether individual gated features are included in the encoded type or
1685+
not.
16811686

16821687
For example, the following WIT document:
16831688
```wit
@@ -1712,5 +1717,5 @@ encoded as:
17121717
))
17131718
)
17141719
```
1715-
Thus, `@since` and `@feature` gates are not part of the runtime semantics of
1720+
Thus, `@since` and `@unstable` gates are not part of the runtime semantics of
17161721
components, just part of the source-level tooling for producing components.

0 commit comments

Comments
 (0)