-
Notifications
You must be signed in to change notification settings - Fork 52
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
JS backend should be more liberal about typing #668
Comments
Similarly, we need toString on all enums |
cc @ambiguousname UX of the JS API is probably an interesting thing to hack on, and probably not too involved. Writing tests is a good way to discover these UX pitfalls, too. |
That would be interesting! I agree, I think this would be fairly easy to set up in the JS API. I really like the idea of checking an object for the right fields inside of our methods instead of being so strict about what we pass in. That would allow us to remove some of the more clunky elements of the API (like And yes, lots of tests would be great. (Edit: Manish's comment below is right, |
we still would need |
I think no matter what once we have a bag of stuff we need some way to share code on how that bag of stuff gets converted to something FFI-compatible. I think |
Mostly I'm annoyed at the |
It also gives the added benefit of cleaning up static intoFFI(object) {
var array = [];
if ("a" in object) {
array.push(diplomatRuntime.someConversionFunction(object.a));
} else {
throw new Error("...");
}
return array;
} |
I think we can make it properly private via a symbol, it should be I still think it should be a method, if we want a higher level |
I think the JS backend should accept objects with the right fields in lieu of struct types, and strings in lieu of enum types.
Basically, if a method
method
accepts structStruct {a: Enum, b: u32}
whereEnum
has variantsFoo, Bar
, it should also be acceptable to invoke it withmethod({a: "foo", b: 1})
.The easiest way to do this is probabyl give every enum and non-out struct a constructor that acceps either the looser typed version, or an instance of itself, and unconditionally call the ctor before doing any JS-to-C shenanigans
The text was updated successfully, but these errors were encountered: