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 Feb 23, 2024
1 parent f0487b2 commit f61d68b
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions design/mvp/WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,16 @@ Concretely, the structure of a world is:
```ebnf
world-item ::= 'world' id '{' world-items* '}'
world-items ::= export-item | import-item | use-item | typedef-item | include-item
world-items ::= export-item | import-item | use-export-item | use-import-item | typedef-item | include-item
export-item ::= 'export' id ':' extern-type
| 'export' use-path ';'
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 @@ -912,6 +915,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;
}
```

## Item: `include`

A `include` statement enables the union of the current world with another world. The structure of an `include` statement is:
Expand Down Expand Up @@ -983,7 +1007,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 f61d68b

Please sign in to comment.