-
Notifications
You must be signed in to change notification settings - Fork 62
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
First-class importable enums and variants #235
Labels
enhancement
New feature or request
Comments
To further elaborate on this support, here is a more involved example of the JCO transpile generation for the following WIT: package foo:bar;
interface bar {
type x = y;
variant y {
a(string),
b(u32)
}
record z {
a: u32
}
enum e {
first,
second,
}
flags f {
a,
b
}
q: func(x: x, y: y, z: z, e: e, f: f);
}
world bar {
export bar;
}
We should support: import { bar } from 'foo:bar';
const { X, Y, E, F } = bar;
bar.q(X.a('string'), Y.a(2), { a: 4 }, E.first, F.a | F.b); Note that only the "primitive types" For |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After discussing this one with @dbaeumer, I think there might be merit in having some kind of first-class runtime primitives for enums and variants.
So instead of passing a string or a
{ tag, val }
object shape, to instead have a singular importable type instance which represents the enum or variant.This would mean, for example, with an interface like HTTP, instead of creating an outgoing request like:
we would instead write:
This would be a major change to the bindgen, but could be worth considering at some point.
The text was updated successfully, but these errors were encountered: