Skip to content

Commit a0ee9bd

Browse files
committed
Update text format for descriptor and describes clauses
Make the `descriptor` and `describes` clauses self-contained extra fields before the comptype rather than having them contain the comptype. As suggested in #29 (comment).
1 parent 0bd9764 commit a0ee9bd

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

proposals/custom-descriptors/Overview.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ what type their custom descriptors have.
4040

4141
```wasm
4242
(rec
43-
(type $foo (descriptor $foo.rtt (struct (field ...))))
44-
(type $foo.rtt (describes $foo (struct (field ...))))
43+
(type $foo (descriptor $foo.rtt) (struct (field ...)))
44+
(type $foo.rtt (describes $foo) (struct (field ...)))
4545
)
4646
```
4747

@@ -59,13 +59,13 @@ but type `$C` is different.
5959

6060
```wasm
6161
(rec
62-
(type $A (descriptor $A.rtt (struct (field i32))))
63-
(type $A.rtt (describes $A (struct (field i32))))
62+
(type $A (descriptor $A.rtt) (struct (field i32)))
63+
(type $A.rtt (describes $A) (struct (field i32)))
6464
)
6565
6666
(rec
67-
(type $B (descriptor $B.rtt (struct (field i32))))
68-
(type $B.rtt (describes $B (struct (field i32))))
67+
(type $B (descriptor $B.rtt) (struct (field i32)))
68+
(type $B.rtt (describes $B) (struct (field i32)))
6969
)
7070
7171
(rec
@@ -80,9 +80,9 @@ creating arbitrarily long chains of meta-descriptors:
8080

8181
```wasm
8282
(rec
83-
(type $foo (descriptor $foo.rtt (struct)))
84-
(type $foo.rtt (describes $foo (descriptor $foo.meta-rtt (struct))))
85-
(type $foo.meta-rtt (describes $foo.rtt (struct)))
83+
(type $foo (descriptor $foo.rtt) (struct))
84+
(type $foo.rtt (describes $foo) (descriptor $foo.meta-rtt) (struct))
85+
(type $foo.meta-rtt (describes $foo.rtt) (struct))
8686
)
8787
```
8888

@@ -97,8 +97,8 @@ which in turn must have a `descriptor` clause referring to the describing type.
9797
```wasm
9898
(rec
9999
(type $A (struct))
100-
(type $B (descriptor $C (struct)))
101-
(type $C (describes $A (struct))) ;; Invalid: must be 'describes $B'
100+
(type $B (descriptor $C) (struct))
101+
(type $C (describes $A) (struct)) ;; Invalid: must be 'describes $B'
102102
)
103103
```
104104

@@ -116,15 +116,15 @@ This is the same strategy we use for ensuring supertype chains do not have cycle
116116
```wasm
117117
(rec
118118
;; Invalid describes clause: $self is not a previously defined type.
119-
(type $self (describes $self (descriptor $self (struct))))
119+
(type $self (describes $self) (descriptor $self) (struct))
120120
121121
;; Invalid describes clause: $pong is not a previously defined type.
122-
(type $ping (describes $pong (descriptor $pong (struct))))
123-
(type $pong (describes $ping (descriptor $ping (struct))))
122+
(type $ping (describes $pong) (descriptor $pong) (struct))
123+
(type $pong (describes $ping) (descriptor $ping) (struct))
124124
125125
;; Invalid describes clause: $foo is not a previously defined type.
126-
(type $foo.rtt (describes $foo (struct)))
127-
(type $foo (descriptor $foo.rtt (struct)))
126+
(type $foo.rtt (describes $foo) (struct))
127+
(type $foo (descriptor $foo.rtt) (struct))
128128
)
129129
```
130130

@@ -164,34 +164,34 @@ might be laid out after the engine-managed RTT for the type they describe.
164164

165165
```wasm
166166
(rec
167-
(type $super (sub (descriptor $super.rtt (struct))))
168-
(type $super.rtt (sub (describes $super (struct))))
167+
(type $super (sub (descriptor $super.rtt) (struct)))
168+
(type $super.rtt (sub (describes $super) (struct)))
169169
170170
;; Ok
171-
(type $sub (sub $super (descriptor $sub.rtt (struct))))
172-
(type $sub.rtt (sub $super.rtt (describes $sub (struct))))
171+
(type $sub (sub $super (descriptor $sub.rtt) (struct)))
172+
(type $sub.rtt (sub $super.rtt (describes $sub) (struct)))
173173
)
174174
175175
(rec
176176
(type $super (sub (struct)))
177177
178178
;; Ok
179-
(type $sub (sub $super (descriptor $sub.rtt (struct))))
180-
(type $sub.rtt (describes $sub (struct)))
179+
(type $sub (sub $super (descriptor $sub.rtt) (struct)))
180+
(type $sub.rtt (describes $sub) (struct))
181181
)
182182
183183
(rec
184-
(type $super (sub (descriptor $super.rtt (struct ))))
185-
(type $super.rtt (sub (describes $super (struct))))
184+
(type $super (sub (descriptor $super.rtt) (struct )))
185+
(type $super.rtt (sub (describes $super) (struct)))
186186
187187
;; Ok (but strange)
188188
(type $other (struct))
189-
(type $sub.rtt (sub $super.rtt (describes $other (struct))))
189+
(type $sub.rtt (sub $super.rtt (describes $other) (struct)))
190190
)
191191
192192
(rec
193-
(type $super (sub (descriptor $super.rtt (struct))))
194-
(type $super.rtt (sub (describes $super (struct))))
193+
(type $super (sub (descriptor $super.rtt) (struct)))
194+
(type $super.rtt (sub (describes $super) (struct)))
195195
196196
;; Invalid: Must be described by an immediate subtype of $super.rtt.
197197
(type $sub (sub $super (struct)))
@@ -201,12 +201,12 @@ might be laid out after the engine-managed RTT for the type they describe.
201201
)
202202
203203
(rec
204-
(type $super (sub (descriptor $super.rtt (struct))))
205-
(type $super.rtt (sub (describes $super (struct))))
204+
(type $super (sub (descriptor $super.rtt) (struct)))
205+
(type $super.rtt (sub (describes $super) (struct)))
206206
207207
;; Invalid: $other.rtt must be a an immediate subtype of $super.rtt.
208-
(type $sub (sub $super (descriptor $other.rtt (struct))))
209-
(type $other.rtt (describes $sub (struct)))
208+
(type $sub (sub $super (descriptor $other.rtt) (struct)))
209+
(type $other.rtt (describes $sub) (struct))
210210
)
211211
```
212212

@@ -226,10 +226,10 @@ This may be relaxed in the future.
226226
```wasm
227227
(rec
228228
;; Invalid: descriptor clauses may only be used with structs.
229-
(type $array (descriptor $array.rtt (array i8)))
229+
(type $array (descriptor $array.rtt) (array i8))
230230
231231
;; Invalid: describes clauses may only be used with structs.
232-
(type $array.rtt (describes $array (func)))
232+
(type $array.rtt (describes $array) (func))
233233
)
234234
```
235235

@@ -242,11 +242,11 @@ this could allow the following unsound program to validate and run:
242242

243243
```wasm
244244
(rec
245-
(type $foo (sub (descriptor $foo.rtt (struct))))
246-
(type $foo.rtt (sub (describes $foo (struct))))
245+
(type $foo (sub (descriptor $foo.rtt) (struct)))
246+
(type $foo.rtt (sub (describes $foo) (struct)))
247247
248-
(type $bar (sub $foo (descriptor $bar.rtt (struct (field $bar-only i32)))))
249-
(type $bar.rtt (sub $foo.rtt (describes $bar (struct))))
248+
(type $bar (sub $foo (descriptor $bar.rtt) (struct (field $bar-only i32))))
249+
(type $bar.rtt (sub $foo.rtt (describes $bar) (struct)))
250250
)
251251
252252
(func $unsound (result i32)
@@ -486,12 +486,12 @@ WebAssembly.
486486
;; counter.wasm
487487
(module
488488
(rec
489-
(type $counter (descriptor $counter.vtable (struct (field $val (mut i32)))))
490-
(type $counter.vtable (describes $counter (struct
489+
(type $counter (descriptor $counter.vtable) (struct (field $val (mut i32))))
490+
(type $counter.vtable (describes $counter) (struct
491491
(field $proto (ref extern))
492492
(field $get (ref $get_t))
493493
(field $inc (ref $inc_t))
494-
)))
494+
))
495495
(type $get_t (func (param (ref null $counter)) (result i32)))
496496
(type $inc_t (func (param (ref null $counter))))
497497
)
@@ -683,12 +683,12 @@ and additionally expose a constructor:
683683
684684
(module
685685
(rec
686-
(type $counter (descriptor $counter.vtable (struct (field $val (mut i32)))))
687-
(type $counter.vtable (describes $counter (struct
686+
(type $counter (descriptor $counter.vtable) (struct (field $val (mut i32))))
687+
(type $counter.vtable (describes $counter) (struct
688688
(field $proto (ref extern))
689689
(field $get (ref $get_t))
690690
(field $inc (ref $inc_t))
691-
)))
691+
))
692692
(type $get_t (func (param (ref null $counter)) (result i32)))
693693
(type $inc_t (func (param (ref null $counter))))
694694
)
@@ -850,11 +850,11 @@ and is included below only to clarify the interaction between proposals.)
850850

851851
```
852852
describedcomptype ::=
853-
| 0x4D x:typeidx ct:comptype => (descriptor x ct)
853+
| 0x4D x:typeidx ct:comptype => (descriptor x) ct
854854
| ct:comptype => ct
855855
856856
describingcomptype ::=
857-
| 0x4C x:typeidx ct:describedcomptype => (describes x ct)
857+
| 0x4C x:typeidx ct:describedcomptype => (describes x) ct
858858
| ct:describedcomptype => ct
859859
860860
sharecomptype ::=

0 commit comments

Comments
 (0)