Open jgravelle-google opened 4 years ago
Thanks for the writeup and agreed that this seems useful and even, for item (4) in your list, necessary. One important detail is that these helper functions should by design be inlineable into the calling adapter function, so that no actual dynamic call stack is needed. In particular, this rules out mutual recursion (one trivial way to implement/specify this is by saying that an adapter function with index i can only call adapter functions with index i-1).
Great proposal and write up, thanks for laying out the motivation so clearly.
We started discussing this in the last video call. I believe it will be useful in a variety of contexts to have helper functions in the interface. I propose allowing something like:
Similar to declarations of imports+exports, but with a body.
Use cases + examples:
dup
,pick
, et al), we can reuse function arguments as a natural scoping mechanism. We need to do something here to avoid duplicating function calls to exports when we want to reference a value twice.For call-defer-export, we could use helper function to defer arbitrary adapter instructions rather than only wasm exports.