Skip to content

Commit 492b109

Browse files
committed
Update the language docs for the targets clause.
1 parent fb7ca26 commit 492b109

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

LANGUAGE.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,41 @@
22

33
WAC is a superset of the [WIT language](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
44

5+
However, unlike WIT, WAC is evaluated in a top-down fashion and is not a
6+
declarative language. Consequently, types must be declared before they are used
7+
in WAC.
8+
59
In addition to being able to declare types, interfaces, and worlds, WAC
610
also allows for defining a _composition_.
711

812
In the simplest terms, a composition is a collection of components that
913
are instantiated in a topological order and certain exports from those
1014
instances are made available as exports of the composition itself.
1115

16+
## Package Directive
17+
18+
Each WAC document must begin with a `package` directive:
19+
20+
```wac
21+
package example:composition;
22+
```
23+
24+
The directive identifies the namespace and name of the package being defined.
25+
26+
Additionally, the `package` directive may include a `targets` clause:
27+
28+
```wac
29+
package example:composition targets wasi:http/proxy;
30+
```
31+
32+
The package path following a `targets` clause must name a world. The parser
33+
will then ensure that the composition is valid for the given world.
34+
35+
If the composition is not valid for the given world, then an error will be
36+
emitted.
37+
38+
## Statements
39+
1240
WAC currently has three statements that extend the WIT language: import
1341
statements, let statements, and export statements.
1442

@@ -398,7 +426,7 @@ export my-instance...;
398426
Then the `run` function exported by the composition will be from the instance
399427
named `b:c` and not the instance named `a:b`.
400428

401-
### WAC Grammar
429+
## WAC Grammar
402430

403431
The current WAC grammar:
404432

0 commit comments

Comments
 (0)