@@ -1051,7 +1051,8 @@ world-items ::= gate world-definition
10511051
10521052world-definition ::= export-item
10531053 | import-item
1054- | use-item
1054+ | use-export-item
1055+ | use-import-item
10551056 | typedef-item
10561057 | include-item
10571058
@@ -1060,6 +1061,9 @@ export-item ::= 'export' id ':' extern-type
10601061import-item ::= 'import' id ':' extern-type
10611062 | 'import' use-path ';'
10621063
1064+ use-import-item ::= 'use' 'import' use-item-body
1065+ use-export-item ::= 'use' 'export' use-item-body
1066+
10631067extern-type ::= func-type ';' | 'interface' '{' interface-items* '}'
10641068```
10651069
@@ -1068,6 +1072,27 @@ from the root of a component and used within functions imported and exported.
10681072The ` interface ` item here additionally defines the grammar for IDs used to refer
10691073to ` interface ` items.
10701074
1075+ The ` use export ` /` use import ` items work just like ` use ` inside an ` interface `
1076+ except that they exclusively refer to exports/imports, respectively. This
1077+ allows a world to import and export the same interface and be able to
1078+ independently refer to same type in both. For example, the following world
1079+ defines a single function using both an imported and exported version of the
1080+ same interface's resource type:
1081+
1082+ ``` wit
1083+ interface i {
1084+ resource r;
1085+ }
1086+
1087+ world w {
1088+ import i;
1089+ export i;
1090+ use import i.{r as r1};
1091+ use export i.{r as r2};
1092+ export transform: func(in: r1) -> r2;
1093+ }
1094+ ```
1095+
10711096[ `componenttype` ] : Explainer.md#type-definitions
10721097
10731098## Item: ` include `
@@ -1144,7 +1169,9 @@ use my:dependency/the-interface.{more, names as foo}
11441169Specifically the structure of this is:
11451170
11461171``` ebnf
1147- use-item ::= 'use' use-path '.' '{' use-names-list '}' ';'
1172+ use-item ::= 'use' use-item-body
1173+
1174+ use-item-body ::= use-path '.' '{' use-names-list '}' ';'
11481175
11491176use-names-list ::= use-names-item
11501177 | use-names-item ',' use-names-list?
0 commit comments