-
Notifications
You must be signed in to change notification settings - Fork 82
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
mapping any
type
#357
Comments
In both the handle and non-handle contexts, I think
Much farther out in the future, there has been early discussion (that we put on hold, since it turned out to be a much bigger bite to chew) around adding a second-class form of generics that, in the context of WIT, we've called "WIT templates". The rough idea is to have a form of early monomorphization (in the spirit of C++ templates, but at link-time instead of individual-component-compile-time) that allowed a component to statically specialize to a particular set of types (thereby avoiding the boxing/unboxing overhead of a universal representation). I hope to return to this after the Component Model MVP is done. |
This sounds like C++'s It can even implement HKT, which is impossible to encode in platforms such as But this is really too far away for us, there are too many details to be finalized, and there are more important things to be stabilized. At this stage, I try to use This is enough for my scenario and is a good temporary solution. Please let me know if the time comes to discuss parametric polymorphism! |
Agreed it's rather like |
Side rant: Only if you don't mind having severely limited parametric polymorphism. For example, C++ cannot have polymorphic virtual methods, which means you cannot implement common patterns like a visitor generically without jumping through hoops. More expressive forms like first-class (or higher-rank) polymorphism or polymorphic recursion are outright impossible under this approach, and so is proper separate compilation, of course (leading to worst-case exponential compile times in C++). |
Is it possible to add any type to the component model, corresponding to anyref (non-nullable) in wasm.
Motivation
I wrote a language and I want to import a generic library from rust. There are two implementations of generics, namely monomorphism and boxing.
My current choice is manual monomorphism and exporting multiple generic versions, which does not have good scalability.
If the any type can be supported, then all generic parameters can be boxed to any, so that rust generics can be imported through ffi.
The text was updated successfully, but these errors were encountered: