Skip to content

Commit a94fbe5

Browse files
macovedjlukewagner
authored andcommitted
explicit package declarations should require root package declaration
1 parent de2bc23 commit a94fbe5

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

design/mvp/WIT.md

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ WIT packages can be defined in a collection of files. At least one of these
6565
files must specify a package name. Multiple files can specify the `package`,
6666
though they must all agree on what the package name is.
6767

68-
Alternatively, many packages can be declared consecutively in one or more
69-
files, if the "explicit" package notation is used:
68+
Additionally, many packages can be declared consecutively in one or more files, if the "explicit" package notation is used:
7069

7170
```wit
7271
package local:a {
@@ -78,6 +77,8 @@ package local:b {
7877
}
7978
```
8079

80+
It is worth noting that when defining packages "explicitly" with a scope, that it does not remove the need for the "root" package declaration above. That is, there must be a single "root" package that is the container of all such "explicitly" defined packages.
81+
8182
Package names are used to generate the [names of imports and exports]
8283
in the Component Model's representation of [`interface`s][interfaces] and
8384
[`world`s][worlds] as described [below](#package-format).
@@ -890,36 +891,15 @@ readability but this isn't required.
890891
Concretely, the structure of a `wit` file is:
891892

892893
```ebnf
893-
wit-file ::= explicit-package-list | implicit-package-definition
894-
```
895-
896-
Files may be organized in two arrangements. The first of these is as a series
897-
of multiple consecutive "explicit" `package ... {...}` declarations, with the
898-
package's contents contained within the brackets.
899-
900-
```ebnf
901-
explicit-package-list ::= explicit-package-definition*
894+
wit-file ::= package-decl? (package-items | explicit-package-definition)*
902895
903896
explicit-package-definition ::= package-decl '{' package-items* '}'
904-
```
905-
906-
Alternatively, a file may "implicitly" consist of an optional `package ...;`
907-
declaration, followed by a list of package items.
908897
909-
```ebnf
910-
implicit-package-definition ::= package-decl? package-items*
911-
```
912-
913-
These two structures cannot be mixed: a file may be written in either in the
914-
explicit or implicit styles, but not both at once.
915-
916-
All other declarations in a `wit` document are tied to a package, and defined
917-
as follows. A package definition consists of one or more such items:
918-
919-
```ebnf
920898
package-items ::= toplevel-use-item | interface-item | world-item
921899
```
922900

901+
Essentially, these top level items are [worlds], [interfaces], [use statements][use] and other package defintions.
902+
923903
### Feature Gates
924904

925905
Various WIT items can be "gated", to reflect the fact that the item is part of

0 commit comments

Comments
 (0)