Conversation
jbourassa
left a comment
There was a problem hiding this comment.
This differs from
Wasmtime, where the caller must do the conversion to ensure the export they want is valid.
I also want to stay close to Wasmtime's API (see #13 (comment)), but in this particular case I didn't see the benefits. Can you expand on why you think the wrapper approach is preferable?
I assumed this was done this way in Wasmtime because of static typing, not ergonomics. The no wrapper version feels more idiomatic Ruby to me. For what it's worth, the Python bindings also return the extern directly, without any wrapper.
| phantom: PhantomData, | ||
| }) | ||
| } | ||
| } |
My thinking is that the implicit behavior could cause some strange, potentially undesirable behavior. For example, both There's also |
I think that makes sense. The price to pay is quite small: typing |
| @@ -89,15 +93,15 @@ impl Instance { | |||
| /// @def exports | |||
| /// @return [Hash{String => Func, Memory}] | |||
There was a problem hiding this comment.
We're gonna have to update that signature, along with Instance#export and Linker#get.
I can take care of it once it's merged though.
Previously,
Externwas implicitly mapped to the underlying variant. For example, aExtern::Funcwould automatically becomeWasmtime::Funcwhen loading the extern in Ruby. This differs fromWasmtime, where the caller must do the conversion to ensure the export they want is valid.To accomplish this, I added a
WrappedStruct<T>helper to codify a bunch of the conversions we were doing previously. This cleans thing up nicely, so I made a proposal tomagnusfor it as well.