WebAssembly / proposal-type-imports

Proposal for Type Imports & Exports
Other
21 stars 7 forks source link

[overview] Expand explanation; add private types #8

Closed rossberg closed 4 years ago

lukewagner commented 4 years ago

@rossberg Ah hah, ok. I had seen the "reinterpret as a struct definition" bit, but I had interpreted it differently. Re-reading it now, I think I see what you're getting at.

So to check my understanding: a type definition (type $T (private i32)) would get desugared into something like (type $T (struct private (field i32))) and private.get $T is then desugared into struct.get $T 0, but since you can add private to arbitrary struct definitions, there is never a need to box a (struct $Fs) inside of a (private (ref (struct $Fs))) because you could just as well have a (struct private $Fs). Also I assume one could have an (array private $elem) and similarly for every other heap type. If that's all right, that sounds great; I really like it.