lann / wasm-wave

Web Assembly Value Encoding
Apache License 2.0
38 stars 6 forks source link

"Empty set" ambiguity #17

Closed lann closed 10 months ago

lann commented 10 months ago

An "empty set" value {} has two possible interpretations: a flags value with zero flags set or a record value with all field values set to none (because "Record entries with the option-typed value none may be omitted").

The WAVE parser in this repo avoids this ambiguity because it is type-driven, but any alternative implementation that wanted to parse to an AST would need to address it.

I see two obvious options:

sunfishcode commented 10 months ago

Additional options:

lann commented 10 months ago

Another option: {:} as "record without explicit fields", which would lead to the nice property that records always contain a : between braces.

lann commented 10 months ago

Yet another option: require that empty flag sets be expressed as :smile:

lann commented 10 months ago

20 adopts {:} for "empty" records.