@@ -155,6 +155,7 @@ explicitly mark where a `core` token might be required. The exception in
155155` core-prefix ` for ` <idx> ` means that, for example, ` core-prefix(<core:funcidx>) `
156156accepts both ` (core func $foo) ` and plain ` $foo ` .
157157
158+
158159### Component Definitions
159160
160161At the top-level, a ` component ` is a sequence of definitions of various kinds:
@@ -173,10 +174,38 @@ definition ::= core-prefix(<core:module>)
173174 | <export>
174175 | <value> 🪙
175176```
176- Components are like Core WebAssembly modules in that their contained
177- definitions are acyclic: definitions can only refer to preceding definitions
178- (in the AST, text format and binary format). However, unlike modules,
179- components can arbitrarily interleave different kinds of definitions.
177+
178+ As suggested by this grammar, unlike in Core WebAssembly modules, component
179+ ` definition ` s can be in any order and a single kind of ` definition ` can appear
180+ multiple times, interleaved with other kinds of ` definition ` s. Moreover, the
181+ order of ` definition ` s in the text format is significant and, unlike Core
182+ WebAssembly, ` definition ` s are not reordered and grouped by the text format.
183+ Furthermore, component ` definition ` s are strictly * acyclic* , such that a given
184+ ` definition ` (in the text or binary format) can only refer to identifiers or
185+ indices introduced by preceding definitions. Based on this, while the following
186+ two core modules are both valid and equivalent (with the first being "desugared"
187+ into the second):
188+ ``` wat
189+ (module
190+ (import "" "f" (func (type $FT)))
191+ (type $FT (func))
192+ )
193+ (module
194+ (type (func))
195+ (import "" "f" (func (type 0)))
196+ )
197+ ```
198+ only the latter component is valid:
199+ ``` wat
200+ ;;(component
201+ ;; (import "f" (func (type $FT))) ❌ $FT not defined
202+ ;; (type $FT (func))
203+ ;;)
204+ (component
205+ (type $FT (func))
206+ (import "f" (func (type $FT)))
207+ )
208+ ```
180209
181210As defined in the previous section, ` core-prefix(<X>) ` adds a ` core ` token after
182211the leftmost parenthesis of ` <X> ` and so, e.g., ` core-prefix(<core:module>) `
0 commit comments