wasm-c-api icon indicating copy to clipboard operation
wasm-c-api copied to clipboard

Why the Extern hierarchy?

Open ratchetfreak opened this issue 6 years ago • 2 comments

It just doesn't add anything. And only feels like oop for the sake of oop.

User code will want to grab the underlying type directly. And forcing everyone through a generic exports() accessor will just hurt performance and usability.

Most of your examples already expose a helper function for it that take hardcoded magic indices for what they need. If the order of exports ever change then they will fail.

ratchetfreak avatar Oct 04 '19 10:10 ratchetfreak

They correspond to the "extern values" in the spec. In particular, that's what module instances take as lists for imports and exports. So you need a common type.

The examples are not necessarily representative of the general case. For example, a generic loader will not have static knowledge about their individual types.

At some level either the engine or the embedder will have to do that downcast, so the cost as a wash. The actual instantiation is orders of magnitude more expensive anyway.

rossberg avatar Oct 04 '19 10:10 rossberg

See also #119.

peter-b avatar Nov 13 '19 12:11 peter-b