gc
gc copied to clipboard
Functions with custom RTT
To be able to downcast functions to more than just their exact type, there ought to be a way to define a function with a custom RTT. The existing form of function definition would be considered a shorthand for one with the canonical RTT that's a direct subtype of funcref.
I think one could also use such an extension to create a function that effectively has no runtime type tag by specifying rtt.canon any.
Do you have an application for downcasting an anyref to a funcref? In #100, there was discussion of how to compile OCaml to the current proposal, e.g. here, and it didn't involve any casts from anyref to funcref. (More generally, it didn't involve casting anything to any sort of function type.)
This actually seems similar to the ideas in https://github.com/WebAssembly/call-tags, just using "RTT" intead of "call tag." This issue may also become moot depending on the results of #275.
We no longer have RTTs in the proposal, so this is not something we need to solve for the MVP.