Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interoperability of array types with host #146

Closed
Horcrux7 opened this issue Oct 4, 2020 · 4 comments
Closed

Interoperability of array types with host #146

Horcrux7 opened this issue Oct 4, 2020 · 4 comments

Comments

@Horcrux7
Copy link

Horcrux7 commented Oct 4, 2020

How would the interoperability of array types with the host (JavaScript) work? For example I have define an i8 array and an import like:

(type $bytes (array (field i8)))
(import "foo" "bar" (func $bar(param $val (ref null $bytes))))

If I call this function, can I expect a Uint8Array in JavaScript and a byte pointer in another host?

If so, shouldn't we then predefine these primitive arrays as own type and add the type mapping to the proposal?

Or is this only possible via interface types? What will I receive without such interface type definition?

@fgmccabe
Copy link

fgmccabe commented Oct 4, 2020

This is not going to work at all without support from some glue code. There is not enough information in the signature. Apart from anything else, the $bytes parameter is (as far as wasm is concerned) an index not an address.

@Horcrux7
Copy link
Author

Horcrux7 commented Oct 4, 2020

This is not going to work at all without support from some glue code.

How should this glue code look? Both already the simplest array types.

the $bytes parameter is (as far as wasm is concerned) an index not an address.

$bytes is a type. If I call the function then I pass a real reference. And a reference is a address. I does not understand what you means.

@tschneidereit
Copy link
Member

@rossberg's proposal has an accompanying proposal on the JS side which lays out how this reflection would work. See this explainer by @lukewagner for how the two interact, and my Typed Objects explainer.

Note that both of these are somewhat outdated by now, but AFAICT the fundamentals haven't changed enough to make these explainers lose all meaning :)

@tlively
Copy link
Member

tlively commented Apr 5, 2022

There's slightly more discussion on arrays in #151, so I'll close this similar issue.

@tlively tlively closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants