Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions design/mvp/Explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,7 @@ import or export itself. For example:
```wat
(component
(import "wasi:http/types@0.2" (version-suffix ".6") (instance ...))
(import "primary" (implements "wasi:keyvalue/store@0.2") (version-suffix ".1") (instance ...))
(import "primary" (implements "local:demo/store@0.2") (version-suffix ".1") (instance ...))
)
```

Expand All @@ -2708,16 +2708,16 @@ import or export the same `interfacename` multiple times (with different names).
For example:
```wat
(component
(import "primary" (implements "wasi:keyvalue/store") (instance ...))
(import "secondary" (implements "wasi:keyvalue/store") (instance ...))
(import "primary" (implements "local:demo/store") (instance ...))
(import "secondary" (implements "local:demo/store") (instance ...))
)
```
This ensures that imports and exports continue to have unique names (so that,
e.g., guest code executing inside this component has distinct `primary`-
and `secondary`-scoped names for all `wasi:keyvalue/store` operations) while
and `secondary`-scoped names for all `local:demo/store` operations) while
still providing the semantic information conveyed by the `interfacename` (so
that, e.g., hosts can implement both imports with a standard static host
`wasi:keyvalue/store` implementation that is dynamically parameterized by the
that, e.g., hosts can implement both imports with a single static host
`local:demo/store` implementation that is dynamically parameterized by the
store names `"primary"` and `"secondary"`).

🏷️ The `external-id` attribute addresses the naming-expressivity gap left
Expand All @@ -2736,16 +2736,16 @@ modules. E.g.:
)
```
Used together, `implements` and `external-id` allow a single component to, e.g.,
import multiple `wasi:keyvalue/store`s using their platform's internal store
import multiple `local:demo/store`s using their platform's internal store
naming scheme without needing to create a separate mapping or name-mangling
scheme:
```wat
(component
(import "users"
(implements "wasi:keyvalue/store") (external-id "user-db-prod:region-a")
(implements "local:demo/store") (external-id "user-db-prod:region-a")
(instance ...))
(import "catalog"
(implements "wasi:keyvalue/store") (external-id "catalog-db-prod:region-a")
(implements "local:demo/store") (external-id "catalog-db-prod:region-a")
(instance ...))
)
```
Expand Down
20 changes: 10 additions & 10 deletions design/mvp/WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -1469,18 +1469,18 @@ world my-component {
or exported with a custom [plain name]. For example:
```wit
world my-world {
import primary: wasi:keyvalue/store;
import secondary: wasi:keyvalue/store;
export my-handler: wasi:http/handler;
import primary: local:demo/store;
import secondary: local:demo/store;
export my-handler: local:demo/handler;
}
```
Here, `primary` and `secondary` are two distinct imports that both have types
based on the `wasi:keyvalue/store` interface. The plain name of the import is
based on the `local:demo/store` interface. The plain name of the import is
the `id` before the colon (e.g., `primary`), not the interface name. This
contrasts with `import wasi:keyvalue/store;` (without the `id :` prefix), which
contrasts with `import local:demo/store;` (without the `id :` prefix), which
would create a single import using the full interface name
`wasi:keyvalue/store`. Similarly, the export `my-handler` has a type derived
from `wasi:http/handler` but uses the plain name `my-handler` instead of the
`local:demo/store`. Similarly, the export `my-handler` has a type derived
from `local:demo/handler` but uses the plain name `my-handler` instead of the
full interface name, which is useful when a component wants to export the same
interface multiple times or simply use a more descriptive name.

Expand All @@ -1495,16 +1495,16 @@ world w {
```

Using both of these features together, a component can import a
`wasi:keyvalue/store` interface multiple times, using whatever platform-defined
`local:demo/store` interface multiple times, using whatever platform-defined
naming scheme so that the component can be deployed directly to the platform
without separate configuration or runtime errors:
```wit
world my-world {
@external-id("user-db-prod:region-a")
import users: wasi:keyvalue/store;
import users: local:demo/store;

@external-id("catalog-db-prod:region-a")
import catalog: wasi:keyvalue/store;
import catalog: local:demo/store;
}
```

Expand Down