-
Notifications
You must be signed in to change notification settings - Fork 130
Add getters and setters (#235) #701
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
e6ab489
9639973
f2aa864
cb43e7e
f230fc0
b08dd0b
56a2d23
417e0ea
bbcfc9f
3572b56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -420,9 +420,11 @@ Notes: | |
| be [strongly-unique]; attributes are ignored. | ||
| * The `externname`s of all exports in a given component, instance, component- | ||
| type or instance-type must be [strongly-unique]; attributes are ignored. | ||
| * Validation requires that `[constructor]`, `[method]` and `[static]` annotated | ||
| `plainname`s only occur on `func` imports or exports and that the first label | ||
| of a `[constructor]`, `[method]` or `[static]` matches the `plainname` of a | ||
| * Validation requires that `plainname`s annotated with `[constructor]`, | ||
| `[method]`, `[static]`, 📡 `[get]`, or 📡 `[set]` only occur on `func` imports | ||
| or exports. | ||
| * Validation requires that, for `plainname`s annotated with `[constructor]`, | ||
| `[method]`, or `[static]`, the first `label` matches the `plainname` of a | ||
| preceding `resource` import or export, respectively, in the same scope | ||
| (component, component type or instance type). | ||
| * 🏷️ Validation requires that `implements`-annotated imports or exports are | ||
|
|
@@ -433,10 +435,28 @@ Notes: | |
| `vec(<attribute>)`, this list is entirely ignored when validating the types | ||
| of components and instances. | ||
| * Validation of `[constructor]` names requires a `func` type whose result type | ||
| is either `(own $R)` or `(result (own $R) E?)` where `$R` is a resource type | ||
| labeled `r`. | ||
| is either `(own $R)` or `(result (own $R) (error $E)?)`, where `$R` is the | ||
| named resource type. | ||
| * Validation of `[method]` names requires the first parameter of the function | ||
| to be `(param "self" (borrow $R))`, where `$R` is the resource labeled `r`. | ||
| to be `(param "self" (borrow $R))`, where `$R` is the named resource type. | ||
| * 📡 Validation of `[get]` names requires that the function have no parameters, | ||
| unless the name is also annotated with `[method]`, in which case `self` must | ||
| be the only parameter. | ||
| * 📡 Validation of `[get]` names requires that the function have a result type. | ||
| * 📡 Validation of `[set]` names requires that the function have exactly one | ||
| parameter, unless the name is also annotated with `[method]`, in which case | ||
| there must be two parameters, the first of which is `self`. | ||
|
bvisness marked this conversation as resolved.
Outdated
|
||
| * 📡 Validation of `[set]` names requires that the function have either no | ||
| result type or a result type of `(result (error $E)?)`. | ||
| * 📡 If a name with `[set]` is defined as an import or export within a | ||
| particular scope, the equivalent name with `[get]` must have already been | ||
| defined as an import or export respectively in that same scope—that is, all | ||
| labels must be equal (before canonicalization), and all annotations must be | ||
| the same except that `[set]` is replaced with `[get]`, and the `[get]` | ||
| import/export must precede the `[set]` import/export. For example, | ||
| `[set]prop` requires `[get]prop`, and `[method][set]foo.bar` requires | ||
| `[method][get]foo.bar`. | ||
|
Comment on lines
+452
to
+459
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this some more:
This makes me lean towards:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea why you think toolchains have no control over the order in which symbols are emitted; Luke already pointed out in this comment that we already have a rule today saying that As for dead code elimination, surely component tooling is generally not quick to delete "unused" functions, because the functions (used or unused) define the component / instance's type. And besides, if some component tooling is indeed performing some kind of whole-component optimization pass, it seems reasonable for it to be aware of constraints on getters and setters.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While at the core wasm level, I think @badeend is right that core symbols are emitted object-file-by-object-file in arbitrary order with no well-defined global order, what we're talking about here is component-level imports and exports that are emitted by
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was indeed conflating core wasm level and component level. Thanks for clarifying |
||
| * 🔀/📡 Functions with `[get]` or `[set]` names must not be `async`. | ||
| * 🔗 Validation requires that `versionsuffix` is preceded by an `interfaceversion` | ||
| matching `canonversion` and that the concatenation of the `canonversion` and | ||
| the `versionsuffix` results in a `valid semver` as defined by | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.