WebAssembly / memory64

Memory with 64-bit indexes
Other
194 stars 21 forks source link

Text format: new abbreviation for inline data? #29

Open tlively opened 1 year ago

tlively commented 1 year ago

The current spec gives this abbreviation for specifying data inline in a memory definition:

'(' 'memory' id? '(' 'data' b*:datastring ')' ')'

The memory limits are inferred from the size of the data string. For back compat, this abbreviation needs to continue specifying a 32-bit memory, but should we add a similar abbreviation for 64-bit memories? As an example:

'(' 'memory' id? '(' 'data' 'i64' b*:datastring ')' ')'

We could also choose not to provide such an abbreviation.

rossberg commented 1 year ago

Yes, makes a lot of sense to me. However, I think the syntax ought to be

'(' 'memory' id? idxtype '(' 'data' datastring ')' ')'

Reason: The index type is part of the memory type, not the data. Inline data (or inline elem) only modifies the preceding syntax of memory (or table) definitions in so far that their limits are omitted.

tlively commented 1 year ago

I agree that syntax would make more sense, but it would mean that a parser that doesn't expand abbreviations wouldn't know from looking at the idxtype token whether to parse a memtype or an idxtype followed by data. That's not a huge problem, but it is a little annoying.

rossberg commented 1 year ago

@tlively, I guess I'm willing to live with that small annoyance. :) The analogous shorthand for tables already works that way, although the order is different there, so the annoyance doesn't come up, I suppose.