-
Notifications
You must be signed in to change notification settings - Fork 73
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
this
arg for methods in JS API
#153
Comments
The Interface Types proposal will have a method (sic) for doing this. |
Where can I see the docs for this? I don't remember seeing it in the proposal. |
@fgmccabe are you thinking of this discussion? WebAssembly/interface-types#87 It seems incomplete and undecided so far. |
Also just want to check if IT is a required dependency for GC to reach its goals, or if they're meant to be separate specs which can be implemented independently? |
We have consensus to have "no-frills" JS interop (#279) in the MVP, so there won't be any way to install custom prototypes on GC objects. Exported accessor functions will be the only way to inspect or modify WasmGC objects from JS. PRs adding ideas for richer interop to the post-MVP doc would be very welcome, though. |
In light of recent discussions about JS interop over on #150 I revisited the MVP-JS.md document.
A common scenario for JS APIs is to pass objects around that have both readable and sometimes writable properties and callable methods; I believe this must be supported also on the "JS typed object" views of GC structs for the goal of code migration to be achieved.
However, while it is apparently possible to attach a prototype object with function reference properties on it when creating a struct type from JavaScript and importing it into Wasm, I don't understand how the methods are supposed to pass a
this
parameter with the target object unless the method functions are also written in JavaScript.This would seem to mean that to create an interoperable struct type you must:
this
argument into the regular argumentsI'm wondering if there might be a way to apply Wasm functions directly to a prototype without an intermediary JavaScript function or if that's considered an unavoidable limitation of this proposal.
The text was updated successfully, but these errors were encountered: