WebAssembly / component-model

Repository for design and specification of the Component Model
Other
914 stars 78 forks source link

WIT: consider dropping `union`s #236

Closed lann closed 11 months ago

lann commented 11 months ago

Unions are uniquely challenging to implement in bindings because their cases do not have kebab-case names. See for example the wit-bindgen Rust generator's awkward solution to this: https://github.com/bytecodealliance/wasmtime/blob/367bdc8c66df62d6854966a90564b42692a3f023/crates/wit-bindgen/src/rust.rs#L317

Rather than expecting each bindings language to come up with a generic naming scheme to handle unions, I think we should put the onus on WIT authors to select reasonable case names on an equivalent variant.

A quick Github search (and review of WASI) suggests that unions are not currently in use outside of tests and samples.

alexcrichton commented 11 months ago

Personally I'd agree with this and would be in favor 👍

lukewagner commented 11 months ago

I'd be fine dropping them too. Initially they were added because the proposal spawned out of Web IDL, which has union. But yeah, I can see how it ends up being a special case for many languages, especially the statically-typed ones.

guybedford commented 11 months ago

Even in JavaScript, they're still tagged awkwardly and don't actually correspond to the IDL / TypeScript equivalents, so this seems fine to me as well.