Skip to content

Commit

Permalink
Split 'use' inside worlds into 'use import' and 'use export'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewagner committed Jul 3, 2024
1 parent 2a3a6dd commit a4dcbe8
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions design/mvp/WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,8 @@ world-items ::= gate world-definition
world-definition ::= export-item
| import-item
| use-item
| use-export-item
| use-import-item
| typedef-item
| include-item
Expand All @@ -1060,6 +1061,9 @@ export-item ::= 'export' id ':' extern-type
import-item ::= 'import' id ':' extern-type
| 'import' use-path ';'
use-import-item ::= 'use' 'import' use-item-body
use-export-item ::= 'use' 'export' use-item-body
extern-type ::= func-type ';' | 'interface' '{' interface-items* '}'
```

Expand All @@ -1068,6 +1072,27 @@ from the root of a component and used within functions imported and exported.
The `interface` item here additionally defines the grammar for IDs used to refer
to `interface` items.

The `use export`/`use import` items work just like `use` inside an `interface`
except that they exclusively refer to exports/imports, respectively. This
allows a world to import and export the same interface and be able to
independently refer to same type in both. For example, the following world
defines a single function using both an imported and exported version of the
same interface's resource type:

```wit
interface i {
resource r;
}
world w {
import i;
export i;
use import i.{r as r1};
use export i.{r as r2};
export transform: func(in: r1) -> r2;
}
```

[`componenttype`]: Explainer.md#type-definitions

## Item: `include`
Expand Down Expand Up @@ -1144,7 +1169,9 @@ use my:dependency/the-interface.{more, names as foo}
Specifically the structure of this is:

```ebnf
use-item ::= 'use' use-path '.' '{' use-names-list '}' ';'
use-item ::= 'use' use-item-body
use-item-body ::= use-path '.' '{' use-names-list '}' ';'
use-names-list ::= use-names-item
| use-names-item ',' use-names-list?
Expand Down

0 comments on commit a4dcbe8

Please sign in to comment.