Skip to content

Explicit package declarations should require root package declaration #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions design/mvp/WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ WIT packages can be defined in a collection of files. At least one of these
files must specify a package name. Multiple files can specify the `package`,
though they must all agree on what the package name is.

Alternatively, many packages can be declared consecutively in one or more
files, if the "explicit" package notation is used:
Additionally, many packages can be declared consecutively in one or more files, if the following nested package notation is used:

```wit
package local:a {
Expand All @@ -78,6 +77,8 @@ package local:b {
}
```

It is worth noting that defining nested packages does not remove the need for the "root" package declaration above. These nested package definitions simply provide the contents of other packages inline so that they don't have to be otherwise resolved via the filesystem or a registry.

Package names are used to generate the [names of imports and exports]
in the Component Model's representation of [`interface`s][interfaces] and
[`world`s][worlds] as described [below](#package-format).
Expand Down Expand Up @@ -890,36 +891,15 @@ readability but this isn't required.
Concretely, the structure of a `wit` file is:

```ebnf
wit-file ::= explicit-package-list | implicit-package-definition
```

Files may be organized in two arrangements. The first of these is as a series
of multiple consecutive "explicit" `package ... {...}` declarations, with the
package's contents contained within the brackets.

```ebnf
explicit-package-list ::= explicit-package-definition*

explicit-package-definition ::= package-decl '{' package-items* '}'
```

Alternatively, a file may "implicitly" consist of an optional `package ...;`
declaration, followed by a list of package items.

```ebnf
implicit-package-definition ::= package-decl? package-items*
```
wit-file ::= package-decl? (package-items | nested-package-definition)*

These two structures cannot be mixed: a file may be written in either in the
explicit or implicit styles, but not both at once.
nested-package-definition ::= package-decl '{' package-items* '}'

All other declarations in a `wit` document are tied to a package, and defined
as follows. A package definition consists of one or more such items:

```ebnf
package-items ::= toplevel-use-item | interface-item | world-item
```

Essentially, these top level items are [worlds], [interfaces], [use statements][use] and other package defintions.

### Feature Gates

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