Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit b736984

Browse files
committed
Add table initialiser (#10)
1 parent 24bb644 commit b736984

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

proposals/function-references/Overview.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Note: In a Wasm engine, function references (whether first-class or as table ent
4646

4747
* Add a block instruction `let (local t*) ... end` for introducing locals with block scope, in order to handle reference types without default initialisation values
4848

49+
* Add an optional initialiser expression to table definitions, for element types that do not have an implicit default value.
50+
4951

5052
### Examples
5153

@@ -150,13 +152,13 @@ Greatest fixpoint (co-inductive interpretation) of the given rules (implying ref
150152

151153
The following rules, now defined in terms of constructed types, replace and extend the rules for [basic reference types](https://github.com/WebAssembly/reference-types/proposals/reference-types/Overview.md#subtyping).
152154

153-
#### Value Types
155+
##### Value Types
154156

155157
* Reference types are covariant in the referenced constructed type
156158
- `(ref <constype1>) <: (ref <constype2>)`
157159
- iff `<constype1> <: <constype2>`
158160

159-
#### Constructed Types
161+
##### Constructed Types
160162

161163
* Type `func` is a subtype of `any`
162164
- `func <: any`
@@ -187,10 +189,7 @@ The following rules, now defined in terms of constructed types, replace and exte
187189

188190
* Function-level locals must have a type that is defaultable.
189191

190-
* Table definitions with non-zero minimum size must have an element type that is defaultable. (Imports are not affected.)
191-
192-
Question:
193-
- Should we introduce a variant of table definition with explicit default initialiser?
192+
* Table definitions with a type that is not defaultable must have an initialiser value. (Imports are not affected.)
194193

195194

196195
### Instructions
@@ -254,7 +253,9 @@ TODO: This assumes that let-bound locals are mutable. Should they be?
254253

255254
### Tables
256255

257-
TODO: How to initialise tables of non-opt element type (init value? init segment?).
256+
* Table definitions have an initialiser value: `(table <tabletype> <constexpr>)`
257+
- `(table <limits> <reftype> <constexpr>) ok` iff `<limits> <reftype> ok` and `<constexpr> : <reftype>`
258+
- `(table <tabletype>)` is shorthand for `(table <tabletype> (ref.null))`
258259

259260

260261
## Binary Format

0 commit comments

Comments
 (0)