-
Notifications
You must be signed in to change notification settings - Fork 7
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
Future extension: builtin string type import #26
Comments
Sure, that'd be nice to have. It'll be more complicated to implement for engines and tools than a non-imported type in the core Wasm spec, but that's nothing new for this proposal. A certain wrinkle is the fact that importing functions with more specific signatures is not exactly backwards-compatible (even though in this particular case for most practically-relevant cases it probably will happen to be compatible by sheer luck). So to maintain 100% formal backwards compatibility (which will probably be a requirement), this will effectively double the number of supported imports. Note that to make the mechanism actually generic/polyfillable (for engines that don't implement built-in strings), a type checking function will have to be imported along with the type, to allow such engines to check that a value passed across the boundary (or an |
Yes, I think we need to have a plan for type imports (although not completely possible without a full type imports design). My sketch plan for the type import was:
Then one of three options seems possible for the functions:
This would cover all of the builtins that generate strings, but not the consumers, which is unfortunate. The advantage is just that this approach is very simple. I haven't found a way to make this work for params.
I think (3) is probably the nicest, but is maybe a little odd. (2) would probably be the fallback then. |
In a future with type imports, we could add a builtin subtype of extern representing JS strings importable as something like
(import "wasm:js-string" "string" (type $string (sub extern)))
. We could then allow the builtin operations to be imported with signatures that accept and return$string
references instead ofextern
references. The benefit of this additional static typing would be that engines would be able to skip the check that the inputs to the builtin operations are actually strings, since the type system would prove that they must be.Does that seem like a reasonable future direction? Are there any foreseeable problems with it?
The text was updated successfully, but these errors were encountered: