@@ -897,13 +897,16 @@ Concretely, the structure of a world is:
897
897
``` ebnf
898
898
world-item ::= 'world' id '{' world-items* '}'
899
899
900
- world-items ::= export-item | import-item | use-item | typedef-item | include-item
900
+ world-items ::= export-item | import-item | use-export-item | use-import- item | typedef-item | include-item
901
901
902
902
export-item ::= 'export' id ':' extern-type
903
903
| 'export' use-path ';'
904
904
import-item ::= 'import' id ':' extern-type
905
905
| 'import' use-path ';'
906
906
907
+ use-import-item ::= 'use' 'import' use-item-body
908
+ use-export-item ::= 'use' 'export' use-item-body
909
+
907
910
extern-type ::= func-type ';' | 'interface' '{' interface-items* '}'
908
911
```
909
912
@@ -912,6 +915,27 @@ from the root of a component and used within functions imported and exported.
912
915
The ` interface ` item here additionally defines the grammar for IDs used to refer
913
916
to ` interface ` items.
914
917
918
+ The ` use export ` /` use import ` items work just like ` use ` inside an ` interface `
919
+ except that they exclusively refer to exports/imports, respectively. This
920
+ allows a world to import and export the same interface and be able to
921
+ independently refer to same type in both. For example, the following world
922
+ defines a single function using both an imported and exported version of the
923
+ same interface's resource type:
924
+
925
+ ``` wit
926
+ interface i {
927
+ resource r;
928
+ }
929
+
930
+ world w {
931
+ import i;
932
+ export i;
933
+ use import i.{r as r1};
934
+ use export i.{r as r2};
935
+ export transform: func(in: r1) -> r2;
936
+ }
937
+ ```
938
+
915
939
## Item: ` include `
916
940
917
941
A ` include ` statement enables the union of the current world with another world. The structure of an ` include ` statement is:
@@ -983,7 +1007,9 @@ use my:dependency/the-interface.{more, names as foo}
983
1007
Specifically the structure of this is:
984
1008
985
1009
``` ebnf
986
- use-item ::= 'use' use-path '.' '{' use-names-list '}' ';'
1010
+ use-item ::= 'use' use-item-body
1011
+
1012
+ use-item-body ::= use-path '.' '{' use-names-list '}' ';'
987
1013
988
1014
use-names-list ::= use-names-item
989
1015
| use-names-item ',' use-names-list?
0 commit comments