Modules

Indices

Indices can be given either in raw numeric form or as symbolic identifiers when bound by a respective construct. Such identifiers are looked up in the suitable space of the identifier context \(I\).

\[\begin{split}\begin{array}{llcllllllll} \def\mathdef3803#1{{}}\mathdef3803{type index} & \href{../text/modules.html#text-typeidx}{\mathtt{typeidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{types}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{function index} & \href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{funcs}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{table index} & \href{../text/modules.html#text-tableidx}{\mathtt{tableidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{tables}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{memory index} & \href{../text/modules.html#text-memidx}{\mathtt{memidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{mems}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{global index} & \href{../text/modules.html#text-globalidx}{\mathtt{globalidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{globals}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{tag index} & \href{../text/modules.html#text-tagidx}{\mathtt{tagidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{tags}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{element index} & \href{../text/modules.html#text-elemidx}{\mathtt{elemidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{elem}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{data index} & \href{../text/modules.html#text-dataidx}{\mathtt{dataidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{data}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{local index} & \href{../text/modules.html#text-localidx}{\mathtt{localidx}}_I &::=& x{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& x \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& x & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{locals}}[x] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{label index} & \href{../text/modules.html#text-labelidx}{\mathtt{labelidx}}_I &::=& l{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& l \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& l & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{labels}}[l] = v) \\ \def\mathdef3803#1{{}}\mathdef3803{field index} & \href{../text/modules.html#text-fieldidx}{\mathtt{fieldidx}}_{I,x} &::=& i{:}\href{../text/values.html#text-int}{\def\mathdef3828#1{{\mathtt{u}#1}}\mathdef3828{\mathtt{32}}} &\Rightarrow& i \\&&|& v{:}\href{../text/values.html#text-id}{\mathtt{id}} &\Rightarrow& i & (\mathrel{\mbox{if}} I.\href{../text/conventions.html#text-context}{\mathsf{fields}}[x][i] = v) \\ \end{array}\end{split}\]

Type Uses

A type use is a reference to a function type definition. It may optionally be augmented by explicit inlined parameter and result declarations. That allows binding symbolic identifiers to name the local indices of parameters. If inline declarations are given, then their types must match the referenced function type.

\[\begin{split}\begin{array}{llcllll} \def\mathdef3803#1{{}}\mathdef3803{type use} & \href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}_I &::=& \def\mathdef3842#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3842{(}~\def\mathdef3843#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3843{type}~~x{:}\href{../text/modules.html#text-typeidx}{\mathtt{typeidx}}_I~\def\mathdef3844#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3844{)} \quad\Rightarrow\quad x, I' \\ &&& \qquad (\mathrel{\mbox{if}} \begin{array}[t]{@{}l@{}} I.\href{../text/conventions.html#text-context}{\mathsf{typedefs}}[x] = \href{../syntax/types.html#syntax-subtype}{\mathsf{sub}}~\href{../syntax/types.html#syntax-subtype}{\mathsf{final}}~(\href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~[t_1^n] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast]) \wedge I' = \{\href{../text/conventions.html#text-context}{\mathsf{locals}}~(\epsilon)^n\}) \\ \end{array} \\[1ex] &&|& \def\mathdef3845#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3845{(}~\def\mathdef3846#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3846{type}~~x{:}\href{../text/modules.html#text-typeidx}{\mathtt{typeidx}}_I~\def\mathdef3847#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3847{)} ~~(t_1{:}\href{../text/types.html#text-functype}{\mathtt{param}})^\ast~~(t_2{:}\href{../text/types.html#text-functype}{\mathtt{result}})^\ast \quad\Rightarrow\quad x, I' \\ &&& \qquad (\mathrel{\mbox{if}} \begin{array}[t]{@{}l@{}} I.\href{../text/conventions.html#text-context}{\mathsf{typedefs}}[x] = \href{../syntax/types.html#syntax-subtype}{\mathsf{sub}}~\href{../syntax/types.html#syntax-subtype}{\mathsf{final}}~(\href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~[t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast]) \wedge I' = \{\href{../text/conventions.html#text-context}{\mathsf{locals}}~\mathrm{id}(\href{../text/types.html#text-functype}{\mathtt{param}})^\ast\} ~\href{../text/conventions.html#text-context-wf}{\mbox{well-formed}}) \\ \end{array} \\ \end{array}\end{split}\]

Note

If inline declarations are given, their types must be syntactically equal to the types from the indexed definition; possible type substitutions from other definitions that might make them equal are not taken into account. This is to simplify syntactic pre-processing.

The synthesized attribute of a \(\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}\) is a pair consisting of both the used type index and the local identifier context containing possible parameter identifiers. The following auxiliary function extracts optional identifiers from parameters:

\[\begin{split}\begin{array}{lcl@{\qquad\qquad}l} \mathrm{id}(\def\mathdef3848#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3848{(}~\def\mathdef3849#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3849{param}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef3850#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3850{)}) &=& \href{../text/values.html#text-id}{\mathtt{id}}^? \\ \end{array}\end{split}\]

Note

Both productions overlap for the case that the function type is \([] \href{../syntax/types.html#syntax-functype}{\rightarrow} []\). However, in that case, they also produce the same results, so that the choice is immaterial.

The well-formedness condition on \(I'\) ensures that the parameters do not contain duplicate identifiers.

Abbreviations

A \(\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}\) may also be replaced entirely by inline parameter and result declarations. In that case, a type index is automatically inserted:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{type use} & (t_1{:}\href{../text/types.html#text-functype}{\mathtt{param}})^\ast~~(t_2{:}\href{../text/types.html#text-functype}{\mathtt{result}})^\ast &\equiv& \def\mathdef3851#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3851{(}~\def\mathdef3852#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3852{type}~~x~\def\mathdef3853#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3853{)}~~\href{../text/types.html#text-functype}{\mathtt{param}}^\ast~~\href{../text/types.html#text-functype}{\mathtt{result}}^\ast \\ \end{array}\end{split}\]

where \(x\) is the smallest existing type index whose recursive type definition in the current module is of the form

\[\def\mathdef3854#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3854{(}~\def\mathdef3855#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3855{rec}~\def\mathdef3856#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3856{(}~\def\mathdef3857#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3857{type}~\def\mathdef3858#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3858{(}~\def\mathdef3859#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3859{sub}~\def\mathdef3860#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3860{final}~~\def\mathdef3861#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3861{(}~\def\mathdef3862#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3862{func}~~\href{../text/types.html#text-functype}{\mathtt{param}}^\ast~~\href{../text/types.html#text-functype}{\mathtt{result}}^\ast~\def\mathdef3863#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3863{)}~\def\mathdef3864#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3864{)}~\def\mathdef3865#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3865{)}~\def\mathdef3866#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3866{)}\]

If no such index exists, then a new recursive type of the same form is inserted at the end of the module.

Abbreviations are expanded in the order they appear, such that previously inserted type definitions are reused by consecutive expansions.

Imports

The descriptors in imports can bind a symbolic function, table, memory, tag, or global identifier.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{import} & \href{../text/modules.html#text-import}{\mathtt{import}}_I &::=& \def\mathdef3867#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3867{(}~\def\mathdef3868#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3868{import}~~\mathit{mod}{:}\href{../text/values.html#text-name}{\mathtt{name}}~~\mathit{nm}{:}\href{../text/values.html#text-name}{\mathtt{name}}~~d{:}\href{../text/modules.html#text-importdesc}{\mathtt{importdesc}}_I~\def\mathdef3869#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3869{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-import}{\mathsf{module}}~\mathit{mod}, \href{../syntax/modules.html#syntax-import}{\mathsf{name}}~\mathit{nm}, \href{../syntax/modules.html#syntax-import}{\mathsf{desc}}~d \} \\[1ex] \def\mathdef3803#1{{}}\mathdef3803{import description} & \href{../text/modules.html#text-importdesc}{\mathtt{importdesc}}_I &::=& \def\mathdef3870#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3870{(}~\def\mathdef3871#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3871{func}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~x,I'{:}\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}_I~\def\mathdef3872#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3872{)} &\Rightarrow& \href{../syntax/modules.html#syntax-importdesc}{\mathsf{func}}~x \\ &&|& \def\mathdef3873#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3873{(}~\def\mathdef3874#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3874{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{tt}{:}\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}_I~\def\mathdef3875#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3875{)} &\Rightarrow& \href{../syntax/modules.html#syntax-importdesc}{\mathsf{table}}~\mathit{tt} \\ &&|& \def\mathdef3876#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3876{(}~\def\mathdef3877#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3877{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{mt}{:}\href{../text/types.html#text-memtype}{\mathtt{memtype}}_I~\def\mathdef3878#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3878{)} &\Rightarrow& \href{../syntax/modules.html#syntax-importdesc}{\mathsf{mem}}~~\mathit{mt} \\ &&|& \def\mathdef3879#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3879{(}~\def\mathdef3880#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3880{global}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{gt}{:}\href{../text/types.html#text-globaltype}{\mathtt{globaltype}}_I~\def\mathdef3881#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3881{)} &\Rightarrow& \href{../syntax/modules.html#syntax-importdesc}{\mathsf{global}}~\mathit{gt} \\ &&|& \def\mathdef3882#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3882{(}~\def\mathdef3883#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3883{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{tt}{:}\href{../text/modules.html#text-tag}{\mathtt{tag}}~\def\mathdef3884#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3884{)} &\Rightarrow& \href{../syntax/modules.html#syntax-importdesc}{\mathsf{tag}}~\mathit{tt} \\ \end{array}\end{split}\]

Abbreviations

As an abbreviation, imports may also be specified inline with function, table, memory, global, or tag definitions; see the respective sections.

Functions

Function definitions can bind a symbolic function identifier, and local identifiers for its parameters and locals.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{function} & \href{../text/modules.html#text-func}{\mathtt{func}}_I &::=& \def\mathdef3885#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3885{(}~\def\mathdef3886#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3886{func}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~x,I'{:}\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}_I~~ (\mathit{loc}{:}\href{../text/modules.html#text-local}{\mathtt{local}}_I)^\ast~~(\mathit{in}{:}\href{../text/instructions.html#text-instr}{\mathtt{instr}}_{I''})^\ast~\def\mathdef3887#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3887{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-func}{\mathsf{type}}~x, \href{../syntax/modules.html#syntax-func}{\mathsf{locals}}~\mathit{loc}^\ast, \href{../syntax/modules.html#syntax-func}{\mathsf{body}}~\mathit{in}^\ast~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}} \} \\ &&& \qquad\qquad\qquad (\mathrel{\mbox{if}} I'' = I \href{../syntax/conventions.html#notation-compose}{\oplus} I' \href{../syntax/conventions.html#notation-compose}{\oplus} \{\href{../text/conventions.html#text-context}{\mathsf{locals}}~\mathrm{id}(\href{../text/modules.html#text-local}{\mathtt{local}})^\ast\} ~\href{../text/conventions.html#text-context-wf}{\mbox{well-formed}}) \\[1ex] \def\mathdef3803#1{{}}\mathdef3803{local} & \href{../text/modules.html#text-local}{\mathtt{local}}_I &::=& \def\mathdef3888#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3888{(}~\def\mathdef3889#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3889{local}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}_I~\def\mathdef3890#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3890{)} \quad\Rightarrow\quad \{ \href{../syntax/modules.html#syntax-local}{\mathsf{type}}~t \} \\ \end{array}\end{split}\]

The definition of the local identifier context \(I''\) uses the following auxiliary function to extract optional identifiers from locals:

\[\begin{split}\begin{array}{lcl@{\qquad\qquad}l} \mathrm{id}(\def\mathdef3891#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3891{(}~\def\mathdef3892#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3892{local}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef3893#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3893{)}) &=& \href{../text/values.html#text-id}{\mathtt{id}}^? \\ \end{array}\end{split}\]

Note

The well-formedness condition on \(I''\) ensures that parameters and locals do not contain duplicate identifiers.

Abbreviations

Multiple anonymous locals may be combined into a single declaration:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{local} & \def\mathdef3894#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3894{(}~~\def\mathdef3895#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3895{local}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3896#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3896{)} &\equiv& (\def\mathdef3897#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3897{(}~~\def\mathdef3898#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3898{local}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3899#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3899{)})^\ast \\ \end{array}\end{split}\]

Functions can be defined as imports or exports inline:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef3900#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3900{(}~\def\mathdef3901#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3901{func}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef3902#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3902{(}~\def\mathdef3903#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3903{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~\def\mathdef3904#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3904{)}~~\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}~\def\mathdef3905#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3905{)} \quad\equiv \\ & \qquad \def\mathdef3906#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3906{(}~\def\mathdef3907#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3907{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~~\def\mathdef3908#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3908{(}~\def\mathdef3909#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3909{func}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}~\def\mathdef3910#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3910{)}~\def\mathdef3911#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3911{)} \\[1ex] & \def\mathdef3912#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3912{(}~\def\mathdef3913#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3913{func}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef3914#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3914{(}~\def\mathdef3915#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3915{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~\def\mathdef3916#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3916{)}~~\dots~\def\mathdef3917#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3917{)} \quad\equiv \\ & \qquad \def\mathdef3918#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3918{(}~\def\mathdef3919#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3919{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~~\def\mathdef3920#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3920{(}~\def\mathdef3921#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3921{func}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef3922#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3922{)}~\def\mathdef3923#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3923{)}~~ \def\mathdef3924#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3924{(}~\def\mathdef3925#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3925{func}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~\dots~\def\mathdef3926#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3926{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Note

The latter abbreviation can be applied repeatedly, if “\(\dots\)” contains additional export clauses. Consequently, a function declaration can contain any number of exports, possibly followed by an import.

Tables

Table definitions can bind a symbolic table identifier.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{table} & \href{../text/modules.html#text-table}{\mathtt{table}}_I &::=& \def\mathdef3927#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3927{(}~\def\mathdef3928#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3928{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{tt}{:}\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}_I~~e{:}\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef3929#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3929{)} &\Rightarrow& \{ \href{../syntax/modules.html#syntax-table}{\mathsf{type}}~\mathit{tt}, \href{../syntax/modules.html#syntax-table}{\mathsf{init}}~e \} \\ \end{array}\end{split}\]

Abbreviations

A table’s initialization expression can be omitted, in which case it defaults to \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref.null}}\):

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef3930#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3930{(}~\def\mathdef3931#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3931{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}~\def\mathdef3932#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3932{)} &\equiv& \def\mathdef3933#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3933{(}~\def\mathdef3934#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3934{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}~~\def\mathdef3935#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3935{(}~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref.null}}~\mathit{ht}~\def\mathdef3936#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3936{)}~\def\mathdef3937#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3937{)} \\ &&& \qquad\qquad (\mathrel{\mbox{if}} \href{../text/types.html#text-tabletype}{\mathtt{tabletype}} = \href{../text/types.html#text-limits}{\mathtt{limits}}~\def\mathdef3938#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3938{(}~\def\mathdef3939#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3939{ref}~\def\mathdef3940#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3940{null}^?~\mathit{ht}~\def\mathdef3941#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3941{)}) \\ \end{array}\end{split}\]

An element segment can be given inline with a table definition, in which case its offset is \(0\) and the limits of the table type are inferred from the length of the given segment:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef3942#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3942{(}~\def\mathdef3943#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3943{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~~\def\mathdef3944#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3944{(}~\def\mathdef3945#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3945{elem}~~\href{../syntax/instructions.html#syntax-expr}{\mathit{expr}}^n{:}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-elemexpr}{\mathtt{elemexpr}})~\def\mathdef3946#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3946{)}~\def\mathdef3947#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3947{)} \quad\equiv \\ & \qquad \def\mathdef3948#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3948{(}~\def\mathdef3949#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3949{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~n~~n~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~\def\mathdef3950#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3950{)} \\ & \qquad \def\mathdef3951#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3951{(}~\def\mathdef3952#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3952{elem}~~\def\mathdef3953#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3953{(}~\def\mathdef3954#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3954{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef3955#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3955{)}~~\def\mathdef3956#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3956{(}~\def\mathdef3957#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3957{i32.const}~~\def\mathdef3958#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3958{0}~\def\mathdef3959#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3959{)}~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-elemexpr}{\mathtt{elemexpr}})~\def\mathdef3960#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3960{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef3961#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3961{(}~\def\mathdef3962#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3962{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~~\def\mathdef3963#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3963{(}~\def\mathdef3964#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3964{elem}~~x^n{:}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}})~\def\mathdef3965#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3965{)}~\def\mathdef3966#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3966{)} \quad\equiv \\ & \qquad \def\mathdef3967#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3967{(}~\def\mathdef3968#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3968{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~n~~n~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~\def\mathdef3969#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3969{)} \\ & \qquad \def\mathdef3970#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3970{(}~\def\mathdef3971#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3971{elem}~~\def\mathdef3972#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3972{(}~\def\mathdef3973#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3973{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef3974#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3974{)}~~\def\mathdef3975#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3975{(}~\def\mathdef3976#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3976{i32.const}~~\def\mathdef3977#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3977{0}~\def\mathdef3978#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3978{)}~~\href{../text/types.html#text-reftype}{\mathtt{reftype}}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\def\mathdef3979#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3979{(}~\def\mathdef3980#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3980{ref.func}~~\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}~\def\mathdef3981#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3981{)})~\def\mathdef3982#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3982{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Tables can be defined as imports or exports inline:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef3983#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3983{(}~\def\mathdef3984#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3984{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef3985#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3985{(}~\def\mathdef3986#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3986{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~\def\mathdef3987#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3987{)}~~\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}~\def\mathdef3988#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3988{)} \quad\equiv \\ & \qquad \def\mathdef3989#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3989{(}~\def\mathdef3990#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3990{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~~\def\mathdef3991#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3991{(}~\def\mathdef3992#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3992{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-tabletype}{\mathtt{tabletype}}~\def\mathdef3993#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3993{)}~\def\mathdef3994#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3994{)} \\[1ex] & \def\mathdef3995#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3995{(}~\def\mathdef3996#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3996{table}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef3997#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3997{(}~\def\mathdef3998#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3998{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~\def\mathdef3999#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3999{)}~~\dots~\def\mathdef4000#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4000{)} \quad\equiv \\ & \qquad \def\mathdef4001#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4001{(}~\def\mathdef4002#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4002{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~~\def\mathdef4003#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4003{(}~\def\mathdef4004#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4004{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef4005#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4005{)}~\def\mathdef4006#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4006{)}~~ \def\mathdef4007#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4007{(}~\def\mathdef4008#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4008{table}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~\dots~\def\mathdef4009#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4009{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Note

The latter abbreviation can be applied repeatedly, if “\(\dots\)” contains additional export clauses. Consequently, a table declaration can contain any number of exports, possibly followed by an import.

Memories

Memory definitions can bind a symbolic memory identifier.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{memory} & \href{../text/modules.html#text-mem}{\mathtt{mem}}_I &::=& \def\mathdef4010#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4010{(}~\def\mathdef4011#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4011{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{mt}{:}\href{../text/types.html#text-memtype}{\mathtt{memtype}}_I~\def\mathdef4012#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4012{)} &\Rightarrow& \{ \href{../syntax/modules.html#syntax-mem}{\mathsf{type}}~\mathit{mt} \} \\ \end{array}\end{split}\]

Abbreviations

A data segment can be given inline with a memory definition, in which case its offset is \(0\) and the limits of the memory type are inferred from the length of the data, rounded up to page size:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef4013#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4013{(}~\def\mathdef4014#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4014{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4015#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4015{(}~\def\mathdef4016#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4016{data}~~b^n{:}\href{../text/modules.html#text-datastring}{\mathtt{datastring}}~\def\mathdef4017#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4017{)}~~\def\mathdef4018#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4018{)} \quad\equiv \\ & \qquad \def\mathdef4019#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4019{(}~\def\mathdef4020#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4020{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~m~~m~\def\mathdef4021#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4021{)} \\ & \qquad \def\mathdef4022#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4022{(}~\def\mathdef4023#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4023{data}~~\def\mathdef4024#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4024{(}~\def\mathdef4025#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4025{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef4026#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4026{)}~~\def\mathdef4027#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4027{(}~\def\mathdef4028#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4028{i32.const}~~\def\mathdef4029#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4029{0}~\def\mathdef4030#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4030{)}~~\href{../text/modules.html#text-datastring}{\mathtt{datastring}}~\def\mathdef4031#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4031{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}, m = \mathrm{ceil}(n / 64\,\mathrm{Ki})) \\ \end{array}\end{split}\]

Memories can be defined as imports or exports inline:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef4032#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4032{(}~\def\mathdef4033#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4033{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4034#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4034{(}~\def\mathdef4035#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4035{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~\def\mathdef4036#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4036{)}~~\href{../text/types.html#text-memtype}{\mathtt{memtype}}~\def\mathdef4037#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4037{)} \quad\equiv \\ & \qquad \def\mathdef4038#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4038{(}~\def\mathdef4039#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4039{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~~\def\mathdef4040#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4040{(}~\def\mathdef4041#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4041{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-memtype}{\mathtt{memtype}}~\def\mathdef4042#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4042{)}~\def\mathdef4043#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4043{)} \\[1ex] & \def\mathdef4044#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4044{(}~\def\mathdef4045#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4045{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4046#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4046{(}~\def\mathdef4047#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4047{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~\def\mathdef4048#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4048{)}~~\dots~\def\mathdef4049#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4049{)} \quad\equiv \\ & \qquad \def\mathdef4050#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4050{(}~\def\mathdef4051#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4051{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~~\def\mathdef4052#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4052{(}~\def\mathdef4053#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4053{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef4054#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4054{)}~\def\mathdef4055#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4055{)}~~ \def\mathdef4056#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4056{(}~\def\mathdef4057#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4057{memory}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~\dots~\def\mathdef4058#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4058{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Note

The latter abbreviation can be applied repeatedly, if “\(\dots\)” contains additional export clauses. Consequently, a memory declaration can contain any number of exports, possibly followed by an import.

Globals

Global definitions can bind a symbolic global identifier.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{global} & \href{../text/modules.html#text-global}{\mathtt{global}}_I &::=& \def\mathdef4059#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4059{(}~\def\mathdef4060#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4060{global}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\mathit{gt}{:}\href{../text/types.html#text-globaltype}{\mathtt{globaltype}}_I~~e{:}\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4061#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4061{)} &\Rightarrow& \{ \href{../syntax/modules.html#syntax-global}{\mathsf{type}}~\mathit{gt}, \href{../syntax/modules.html#syntax-global}{\mathsf{init}}~e \} \\ \end{array}\end{split}\]

Abbreviations

Globals can be defined as imports or exports inline:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef4062#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4062{(}~\def\mathdef4063#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4063{global}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4064#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4064{(}~\def\mathdef4065#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4065{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~\def\mathdef4066#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4066{)}~~\href{../text/types.html#text-globaltype}{\mathtt{globaltype}}~\def\mathdef4067#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4067{)} \quad\equiv \\ & \qquad \def\mathdef4068#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4068{(}~\def\mathdef4069#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4069{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~~\def\mathdef4070#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4070{(}~\def\mathdef4071#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4071{global}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/types.html#text-globaltype}{\mathtt{globaltype}}~\def\mathdef4072#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4072{)}~\def\mathdef4073#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4073{)} \\[1ex] & \def\mathdef4074#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4074{(}~\def\mathdef4075#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4075{global}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4076#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4076{(}~\def\mathdef4077#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4077{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~\def\mathdef4078#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4078{)}~~\dots~\def\mathdef4079#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4079{)} \quad\equiv \\ & \qquad \def\mathdef4080#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4080{(}~\def\mathdef4081#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4081{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~~\def\mathdef4082#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4082{(}~\def\mathdef4083#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4083{global}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef4084#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4084{)}~\def\mathdef4085#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4085{)}~~ \def\mathdef4086#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4086{(}~\def\mathdef4087#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4087{global}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~\dots~\def\mathdef4088#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4088{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Note

The latter abbreviation can be applied repeatedly, if “\(\dots\)” contains additional export clauses. Consequently, a global declaration can contain any number of exports, possibly followed by an import.

Tags

An tag definition can bind a symbolic tag identifier.

\[\begin{split}\begin{array}{llcl} \def\mathdef3803#1{{}}\mathdef3803{tag} & \href{../text/modules.html#text-tag}{\mathtt{tag}}_I &::=& \def\mathdef4089#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4089{(}~\def\mathdef4090#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4090{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~x,I'{:}\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}_I~\def\mathdef4091#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4091{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-tag}{\mathsf{type}}~x \} \\ \end{array}\end{split}\]

Abbreviations

Tags can be defined as imports or exports inline:

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{module field} & \def\mathdef4092#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4092{(}~\def\mathdef4093#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4093{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4094#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4094{(}~\def\mathdef4095#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4095{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~\def\mathdef4096#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4096{)}~~\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}~\def\mathdef4097#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4097{)} \quad\equiv \\ & \qquad \def\mathdef4098#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4098{(}~\def\mathdef4099#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4099{import}~~\href{../text/values.html#text-name}{\mathtt{name}}_1~~\href{../text/values.html#text-name}{\mathtt{name}}_2~~\def\mathdef4100#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4100{(}~\def\mathdef4101#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4101{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\href{../text/modules.html#text-typeuse}{\mathtt{typeuse}}~\def\mathdef4102#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4102{)}~\def\mathdef4103#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4103{)} \\[1ex] & \def\mathdef4104#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4104{(}~\def\mathdef4105#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4105{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4106#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4106{(}~\def\mathdef4107#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4107{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~\def\mathdef4108#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4108{)}~~\dots~\def\mathdef4109#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4109{)} \quad\equiv \\ & \qquad \def\mathdef4110#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4110{(}~\def\mathdef4111#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4111{export}~~\href{../text/values.html#text-name}{\mathtt{name}}~~\def\mathdef4112#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4112{(}~\def\mathdef4113#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4113{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}'~\def\mathdef4114#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4114{)}~\def\mathdef4115#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4115{)}~~ \def\mathdef4116#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4116{(}~\def\mathdef4117#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4117{tag}~~\href{../text/values.html#text-id}{\mathtt{id}}'~~\dots~\def\mathdef4118#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4118{)} \\ & \qquad\qquad (\mathrel{\mbox{if}} \href{../text/values.html#text-id}{\mathtt{id}}^? \neq \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' = \href{../text/values.html#text-id}{\mathtt{id}}^? \vee \href{../text/values.html#text-id}{\mathtt{id}}^? = \epsilon \wedge \href{../text/values.html#text-id}{\mathtt{id}}' ~\href{../text/values.html#text-id-fresh}{\mbox{fresh}}) \\ \end{array}\end{split}\]

Note

The latter abbreviation can be applied repeatedly, if “\(\dots\)” contains additional export clauses. Consequently, a memory declaration can contain any number of exports, possibly followed by an import.

Exports

The syntax for exports mirrors their abstract syntax directly.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{export} & \href{../text/modules.html#text-export}{\mathtt{export}}_I &::=& \def\mathdef4119#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4119{(}~\def\mathdef4120#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4120{export}~~\mathit{nm}{:}\href{../text/values.html#text-name}{\mathtt{name}}~~d{:}\href{../text/modules.html#text-exportdesc}{\mathtt{exportdesc}}_I~\def\mathdef4121#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4121{)} &\Rightarrow& \{ \href{../syntax/modules.html#syntax-export}{\mathsf{name}}~\mathit{nm}, \href{../syntax/modules.html#syntax-export}{\mathsf{desc}}~d \} \\ \def\mathdef3803#1{{}}\mathdef3803{export description} & \href{../text/modules.html#text-exportdesc}{\mathtt{exportdesc}}_I &::=& \def\mathdef4122#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4122{(}~\def\mathdef4123#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4123{func}~~x{:}\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I~\def\mathdef4124#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4124{)} &\Rightarrow& \href{../syntax/modules.html#syntax-exportdesc}{\mathsf{func}}~x \\ &&|& \def\mathdef4125#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4125{(}~\def\mathdef4126#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4126{table}~~x{:}\href{../text/modules.html#text-tableidx}{\mathtt{tableidx}}_I~\def\mathdef4127#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4127{)} &\Rightarrow& \href{../syntax/modules.html#syntax-exportdesc}{\mathsf{table}}~x \\ &&|& \def\mathdef4128#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4128{(}~\def\mathdef4129#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4129{memory}~~x{:}\href{../text/modules.html#text-memidx}{\mathtt{memidx}}_I~\def\mathdef4130#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4130{)} &\Rightarrow& \href{../syntax/modules.html#syntax-exportdesc}{\mathsf{mem}}~x \\ &&|& \def\mathdef4131#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4131{(}~\def\mathdef4132#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4132{global}~~x{:}\href{../text/modules.html#text-globalidx}{\mathtt{globalidx}}_I~\def\mathdef4133#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4133{)} &\Rightarrow& \href{../syntax/modules.html#syntax-exportdesc}{\mathsf{global}}~x \\&&|& \def\mathdef4134#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4134{(}~\def\mathdef4135#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4135{tag}~~x{:}\href{../text/modules.html#text-tagidx}{\mathtt{tagidx}}_I~\def\mathdef4136#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4136{)} &\Rightarrow& \href{../syntax/modules.html#syntax-exportdesc}{\mathsf{tag}}~x \\ \end{array}\end{split}\]

Abbreviations

As an abbreviation, exports may also be specified inline with function, table, memory, global, or tag definitions; see the respective sections.

Start Function

A start function is defined in terms of its index.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{start function} & \href{../text/modules.html#text-start}{\mathtt{start}}_I &::=& \def\mathdef4137#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4137{(}~\def\mathdef4138#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4138{start}~~x{:}\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I~\def\mathdef4139#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4139{)} &\Rightarrow& \{ \href{../syntax/modules.html#syntax-start}{\mathsf{func}}~x \} \\ \end{array}\end{split}\]

Note

At most one start function may occur in a module, which is ensured by a suitable side condition on the \(\href{../text/modules.html#text-module}{\mathtt{module}}\) grammar.

Element Segments

Element segments allow for an optional table index to identify the table to initialize.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{element segment} & \href{../text/modules.html#text-elem}{\mathtt{elem}}_I &::=& \def\mathdef4140#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4140{(}~\def\mathdef4141#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4141{elem}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~(et, y^\ast){:}\href{../text/modules.html#text-elemlist}{\mathtt{elemlist}}_I~\def\mathdef4142#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4142{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-elem}{\mathsf{type}}~et, \href{../syntax/modules.html#syntax-elem}{\mathsf{init}}~y^\ast, \href{../syntax/modules.html#syntax-elem}{\mathsf{mode}}~\href{../syntax/modules.html#syntax-elemmode}{\mathsf{passive}} \} \\ &&|& \def\mathdef4143#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4143{(}~\def\mathdef4144#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4144{elem}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~x{:}\href{../text/modules.html#text-tableuse}{\mathtt{tableuse}}_I~~\def\mathdef4145#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4145{(}~\def\mathdef4146#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4146{offset}~~e{:}\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4147#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4147{)}~~(et, y^\ast){:}\href{../text/modules.html#text-elemlist}{\mathtt{elemlist}}_I~\def\mathdef4148#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4148{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-elem}{\mathsf{type}}~et, \href{../syntax/modules.html#syntax-elem}{\mathsf{init}}~y^\ast, \href{../syntax/modules.html#syntax-elem}{\mathsf{mode}}~\href{../syntax/modules.html#syntax-elemmode}{\mathsf{active}}~\{ \href{../syntax/modules.html#syntax-elem}{\mathsf{table}}~x, \href{../syntax/modules.html#syntax-elem}{\mathsf{offset}}~e \} \} \\ &&& \def\mathdef4149#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4149{(}~\def\mathdef4150#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4150{elem}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4151#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4151{declare}~~(et, y^\ast){:}\href{../text/modules.html#text-elemlist}{\mathtt{elemlist}}_I~\def\mathdef4152#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4152{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-elem}{\mathsf{type}}~et, \href{../syntax/modules.html#syntax-elem}{\mathsf{init}}~y^\ast, \href{../syntax/modules.html#syntax-elem}{\mathsf{mode}}~\href{../syntax/modules.html#syntax-elemmode}{\mathsf{declarative}} \} \\ \def\mathdef3803#1{{}}\mathdef3803{element list} & \href{../text/modules.html#text-elemlist}{\mathtt{elemlist}}_I &::=& t{:}\href{../text/types.html#text-reftype}{\mathtt{reftype}}_I~~y^\ast{:}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-elemexpr}{\mathtt{elemexpr}}_I) \qquad\Rightarrow\quad ( \href{../syntax/modules.html#syntax-elem}{\mathsf{type}}~t, \href{../syntax/modules.html#syntax-elem}{\mathsf{init}}~y^\ast ) \\ \def\mathdef3803#1{{}}\mathdef3803{element expression} & \href{../text/modules.html#text-elemexpr}{\mathtt{elemexpr}}_I &::=& \def\mathdef4153#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4153{(}~\def\mathdef4154#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4154{item}~~e{:}\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4155#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4155{)} \quad\Rightarrow\quad e \\ \def\mathdef3803#1{{}}\mathdef3803{table use} & \href{../text/modules.html#text-tableuse}{\mathtt{tableuse}}_I &::=& \def\mathdef4156#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4156{(}~\def\mathdef4157#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4157{table}~~x{:}\href{../text/modules.html#text-tableidx}{\mathtt{tableidx}}_I ~\def\mathdef4158#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4158{)} \quad\Rightarrow\quad x \\ \end{array}\end{split}\]

Abbreviations

As an abbreviation, a single instruction may occur in place of the offset of an active element segment or as an element expression:

\[\begin{split}\begin{array}{llcll} \def\mathdef3803#1{{}}\mathdef3803{element offset} & \def\mathdef4159#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4159{(}~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4160#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4160{)} &\equiv& \def\mathdef4161#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4161{(}~\def\mathdef4162#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4162{offset}~~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4163#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4163{)} \\ \def\mathdef3803#1{{}}\mathdef3803{element item} & \def\mathdef4164#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4164{(}~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4165#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4165{)} &\equiv& \def\mathdef4166#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4166{(}~\def\mathdef4167#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4167{item}~~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4168#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4168{)} \\ \end{array}\end{split}\]

Also, the element list may be written as just a sequence of function indices:

\[\begin{array}{llcll} \def\mathdef3803#1{{}}\mathdef3803{element list} & \def\mathdef4169#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4169{func}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I) &\equiv& \def\mathdef4170#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4170{(ref}~\def\mathdef4171#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4171{func)}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\def\mathdef4172#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4172{(}~\def\mathdef4173#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4173{ref.func}~~\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I~\def\mathdef4174#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4174{)}) \end{array}\]

A table use can be omitted, defaulting to \(\mathtt{0}\). Furthermore, for backwards compatibility with earlier versions of WebAssembly, if the table use is omitted, the \(\def\mathdef4175#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4175{func}\) keyword can be omitted as well.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{table use} & \epsilon &\equiv& \def\mathdef4176#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4176{(}~\def\mathdef4177#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4177{table}~~\def\mathdef4178#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4178{0}~\def\mathdef4179#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4179{)} \\ \def\mathdef3803#1{{}}\mathdef3803{element segment} & \def\mathdef4180#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4180{(}~\def\mathdef4181#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4181{elem}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4182#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4182{(}~\def\mathdef4183#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4183{offset}~~\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4184#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4184{)}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I)~\def\mathdef4185#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4185{)} &\equiv& \def\mathdef4186#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4186{(}~\def\mathdef4187#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4187{elem}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~\def\mathdef4188#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4188{(}~\def\mathdef4189#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4189{table}~~\def\mathdef4190#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4190{0}~\def\mathdef4191#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4191{)}~~\def\mathdef4192#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4192{(}~\def\mathdef4193#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4193{offset}~~\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4194#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4194{)}~~\def\mathdef4195#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4195{func}~~\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/modules.html#text-funcidx}{\mathtt{funcidx}}_I)~\def\mathdef4196#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4196{)} \end{array}\end{split}\]

As another abbreviation, element segments may also be specified inline with table definitions; see the respective section.

Data Segments

Data segments allow for an optional memory index to identify the memory to initialize. The data is written as a string, which may be split up into a possibly empty sequence of individual string literals.

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{data segment} & \href{../text/modules.html#text-data}{\mathtt{data}}_I &::=& \def\mathdef4197#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4197{(}~\def\mathdef4198#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4198{data}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~b^\ast{:}\href{../text/modules.html#text-datastring}{\mathtt{datastring}}~\def\mathdef4199#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4199{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-data}{\mathsf{init}}~b^\ast, \href{../syntax/modules.html#syntax-data}{\mathsf{mode}}~\href{../syntax/modules.html#syntax-datamode}{\mathsf{passive}} \} \\ &&|& \def\mathdef4200#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4200{(}~\def\mathdef4201#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4201{data}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~x{:}\href{../text/modules.html#text-memuse}{\mathtt{memuse}}_I~~\def\mathdef4202#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4202{(}~\def\mathdef4203#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4203{offset}~~e{:}\href{../text/instructions.html#text-expr}{\mathtt{expr}}_I~\def\mathdef4204#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4204{)}~~b^\ast{:}\href{../text/modules.html#text-datastring}{\mathtt{datastring}}~\def\mathdef4205#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4205{)} \\ &&& \qquad \Rightarrow\quad \{ \href{../syntax/modules.html#syntax-data}{\mathsf{init}}~b^\ast, \href{../syntax/modules.html#syntax-data}{\mathsf{mode}}~\href{../syntax/modules.html#syntax-datamode}{\mathsf{active}}~\{ \href{../syntax/modules.html#syntax-data}{\mathsf{memory}}~x', \href{../syntax/modules.html#syntax-data}{\mathsf{offset}}~e \} \} \\ \def\mathdef3803#1{{}}\mathdef3803{data string} & \href{../text/modules.html#text-datastring}{\mathtt{datastring}} &::=& (b^\ast{:}\href{../text/values.html#text-string}{\mathtt{string}})^\ast \quad\Rightarrow\quad \href{../syntax/conventions.html#notation-concat}{\mathrm{concat}}((b^\ast)^\ast) \\ \def\mathdef3803#1{{}}\mathdef3803{memory use} & \href{../text/modules.html#text-memuse}{\mathtt{memuse}}_I &::=& \def\mathdef4206#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4206{(}~\def\mathdef4207#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4207{memory}~~x{:}\href{../text/modules.html#text-memidx}{\mathtt{memidx}}_I ~\def\mathdef4208#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4208{)} \quad\Rightarrow\quad x \\ \end{array}\end{split}\]

Note

In the current version of WebAssembly, the only valid memory index is 0 or a symbolic memory identifier resolving to the same value.

Abbreviations

As an abbreviation, a single instruction may occur in place of the offset of an active data segment:

\[\begin{array}{llcll} \def\mathdef3803#1{{}}\mathdef3803{data offset} & \def\mathdef4209#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4209{(}~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4210#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4210{)} &\equiv& \def\mathdef4211#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4211{(}~\def\mathdef4212#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4212{offset}~~\href{../text/instructions.html#text-instr}{\mathtt{instr}}~\def\mathdef4213#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4213{)} \end{array}\]

Also, a memory use can be omitted, defaulting to \(\mathtt{0}\).

\[\begin{split}\begin{array}{llclll} \def\mathdef3803#1{{}}\mathdef3803{memory use} & \epsilon &\equiv& \def\mathdef4214#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4214{(}~\def\mathdef4215#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4215{memory}~~\def\mathdef4216#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4216{0}~\def\mathdef4217#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4217{)} \\ \end{array}\end{split}\]

As another abbreviation, data segments may also be specified inline with memory definitions; see the respective section.

Modules

A module consists of a sequence of fields that can occur in any order. All definitions and their respective bound identifiers scope over the entire module, including the text preceding them.

A module may optionally bind an identifier that names the module. The name serves a documentary role only.

Note

Tools may include the module name in the name section of the binary format.

\[\begin{split}\begin{array}{lll} \def\mathdef3803#1{{}}\mathdef3803{module} & \href{../text/modules.html#text-module}{\mathtt{module}} & \begin{array}[t]{@{}cllll} ::=& \def\mathdef4218#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4218{(}~\def\mathdef4219#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4219{module}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~(m{:}\href{../text/modules.html#text-modulefield}{\mathtt{modulefield}}_I)^\ast~\def\mathdef4220#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4220{)} \quad\Rightarrow\quad \href{../syntax/conventions.html#notation-compose}{\bigoplus} m^\ast \\ &\qquad (\mathrel{\mbox{if}} I = \href{../syntax/conventions.html#notation-compose}{\bigoplus} \mathrm{idc}(\href{../text/modules.html#text-modulefield}{\mathtt{modulefield}})^\ast ~\href{../text/conventions.html#text-context-wf}{\mbox{well-formed}}) \\ \end{array} \\[1ex] \def\mathdef3803#1{{}}\mathdef3803{module field} & \href{../text/modules.html#text-modulefield}{\mathtt{modulefield}}_I & \begin{array}[t]{@{}clll} ::=& \mathit{ty}^\ast{:}\href{../text/types.html#text-rectype}{\mathtt{rectype}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{types}}~\mathit{ty}^\ast\} \\ |& \mathit{im}{:}\href{../text/modules.html#text-import}{\mathtt{import}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{imports}}~\mathit{im}\} \\ |& \mathit{fn}{:}\href{../text/modules.html#text-func}{\mathtt{func}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{funcs}}~\mathit{fn}\} \\ |& \mathit{ta}{:}\href{../text/modules.html#text-table}{\mathtt{table}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{tables}}~\mathit{ta}\} \\ |& \mathit{me}{:}\href{../text/modules.html#text-mem}{\mathtt{mem}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{mems}}~\mathit{me}\} \\ |& \mathit{gl}{:}\href{../text/modules.html#text-global}{\mathtt{global}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{globals}}~\mathit{gl}\} \\ |& \mathit{tg}{:}\href{../text/modules.html#text-tag}{\mathtt{tag}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{tags}}~\mathit{tg}\} \\ |& \mathit{el}{:}\href{../text/modules.html#text-elem}{\mathtt{elem}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{elems}}~\mathit{el}\} \\ |& \mathit{da}{:}\href{../text/modules.html#text-data}{\mathtt{data}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{datas}}~\mathit{da}\} \\ |& \mathit{st}{:}\href{../text/modules.html#text-start}{\mathtt{start}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{start}}~\mathit{st}\} \\ |& \mathit{ex}{:}\href{../text/modules.html#text-export}{\mathtt{export}}_I &\Rightarrow& \{\href{../syntax/modules.html#syntax-module}{\mathsf{exports}}~\mathit{ex}\} \\ \end{array} \end{array}\end{split}\]

The following restrictions are imposed on the composition of modules: \(m_1 \href{../syntax/conventions.html#notation-compose}{\oplus} m_2\) is defined if and only if

  • \(m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{start}} = \epsilon \vee m_2.\href{../syntax/modules.html#syntax-module}{\mathsf{start}} = \epsilon\)

  • \(m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{funcs}} = m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{tables}} = m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{mems}} = m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{globals}} = m_1.\href{../syntax/modules.html#syntax-module}{\mathsf{tags}} = \epsilon \vee m_2.\href{../syntax/modules.html#syntax-module}{\mathsf{imports}} = \epsilon\)

Note

The first condition ensures that there is at most one start function. The second condition enforces that all imports must occur before any regular definition of a function, table, memory, global, or tag, thereby maintaining the ordering of the respective index spaces.

The well-formedness condition on \(I\) in the grammar for \(\href{../text/modules.html#text-module}{\mathtt{module}}\) ensures that no namespace contains duplicate identifiers.

The definition of the initial identifier context \(I\) uses the following auxiliary definition which maps each relevant definition to a singular context with one (possibly empty) identifier:

\[\begin{split}\begin{array}{@{}lcl@{\qquad\qquad}l} \mathrm{idc}(\def\mathdef4221#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4221{(}~\def\mathdef4222#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4222{rec}~~\href{../text/types.html#text-typedef}{\mathtt{typedef}}^\ast~\def\mathdef4223#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4223{)}) &=& \href{../syntax/conventions.html#notation-compose}{\bigoplus} \mathrm{idc}(\href{../text/types.html#text-typedef}{\mathtt{typedef}})^\ast \\ \mathrm{idc}(\def\mathdef4224#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4224{(}~\def\mathdef4225#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4225{type}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\href{../text/types.html#text-subtype}{\mathtt{subtype}}~\def\mathdef4226#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4226{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{types}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?), \href{../text/conventions.html#text-context}{\mathsf{fields}}~\mathrm{idf}(\href{../text/types.html#text-subtype}{\mathtt{subtype}}), \href{../text/conventions.html#text-context}{\mathsf{typedefs}}~\mathit{st}\} \\ \mathrm{idc}(\def\mathdef4227#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4227{(}~\def\mathdef4228#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4228{func}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4229#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4229{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{funcs}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4230#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4230{(}~\def\mathdef4231#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4231{table}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4232#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4232{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{tables}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4233#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4233{(}~\def\mathdef4234#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4234{memory}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4235#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4235{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{mems}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4236#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4236{(}~\def\mathdef4237#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4237{global}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4238#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4238{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{globals}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4239#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4239{(}~\def\mathdef4240#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4240{tag}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4241#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4241{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{tags}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4242#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4242{(}~\def\mathdef4243#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4243{elem}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4244#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4244{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{elem}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4245#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4245{(}~\def\mathdef4246#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4246{data}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4247#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4247{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{data}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4248#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4248{(}~\def\mathdef4249#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4249{import}~\dots~\def\mathdef4250#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4250{(}~\def\mathdef4251#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4251{func}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4252#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4252{)}~\def\mathdef4253#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4253{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{funcs}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4254#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4254{(}~\def\mathdef4255#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4255{import}~\dots~\def\mathdef4256#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4256{(}~\def\mathdef4257#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4257{table}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4258#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4258{)}~\def\mathdef4259#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4259{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{tables}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4260#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4260{(}~\def\mathdef4261#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4261{import}~\dots~\def\mathdef4262#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4262{(}~\def\mathdef4263#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4263{memory}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4264#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4264{)}~\def\mathdef4265#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4265{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{mems}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4266#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4266{(}~\def\mathdef4267#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4267{import}~\dots~\def\mathdef4268#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4268{(}~\def\mathdef4269#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4269{global}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4270#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4270{)}~\def\mathdef4271#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4271{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{globals}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4272#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4272{(}~\def\mathdef4273#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4273{import}~\dots~\def\mathdef4274#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4274{(}~\def\mathdef4275#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4275{tag}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4276#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4276{)}~\def\mathdef4277#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4277{)}) &=& \{\href{../text/conventions.html#text-context}{\mathsf{tags}}~(\href{../text/values.html#text-id}{\mathtt{id}}^?)\} \\ \mathrm{idc}(\def\mathdef4278#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4278{(}~\dots~\def\mathdef4279#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4279{)}) &=& \{\} \\[2ex] \mathrm{idf}(\def\mathdef4280#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4280{(}~\def\mathdef4281#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4281{sub}~\dots~\href{../text/types.html#text-comptype}{\mathtt{comptype}}~\def\mathdef4282#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4282{)}) &=& \mathrm{idf}(\href{../text/types.html#text-comptype}{\mathtt{comptype}}) \\ \mathrm{idf}(\def\mathdef4283#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4283{(}~\def\mathdef4284#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4284{struct}~\mathit{Tfield}^\ast~\def\mathdef4285#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4285{)}) &=& \href{../syntax/conventions.html#notation-compose}{\bigoplus} \mathrm{idf}(\href{../text/types.html#text-structtype}{\mathtt{field}})^\ast \\ \mathrm{idf}(\def\mathdef4286#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4286{(}~\def\mathdef4287#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4287{array}~\dots~\def\mathdef4288#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4288{)}) &=& \epsilon \\ \mathrm{idf}(\def\mathdef4289#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4289{(}~\def\mathdef4290#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4290{func}~\dots~\def\mathdef4291#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4291{)}) &=& \epsilon \\ \mathrm{idf}(\def\mathdef4292#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4292{(}~\def\mathdef4293#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4293{field}~\href{../text/values.html#text-id}{\mathtt{id}}^?~\dots~\def\mathdef4294#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4294{)}) &=& \href{../text/values.html#text-id}{\mathtt{id}}^? \\ \end{array}\end{split}\]

Abbreviations

In a source file, the toplevel \(\mathtt{(module}~\dots\mathtt{)}\) surrounding the module body may be omitted.

\[\begin{array}{llcll} \def\mathdef3803#1{{}}\mathdef3803{module} & \href{../text/modules.html#text-modulefield}{\mathtt{modulefield}}^\ast &\equiv& \def\mathdef4295#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4295{(}~\def\mathdef4296#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4296{module}~~\href{../text/modules.html#text-modulefield}{\mathtt{modulefield}}^\ast~\def\mathdef4297#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef4297{)} \end{array}\]