-
Notifications
You must be signed in to change notification settings - Fork 246
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
wit: propose to propogate World's name to inline Interfaces' names #1805
Comments
The original intention was that codegen based on a world would use the For the package-depending-on-itself I think that's a bug that shouldn't be too hard to fix. Want to open a dedicated issue for that? |
Thanks for the explanation. I understand the design better now. I guess we can push the logic of "guessing" interface names from the package example:name;
interface exports {
foo: func();
}
world only-exports {
export example:name/exports;
export exports: interface {
foo: func();
}
} Then, there is no ambiguity over the question "what's the name of the interface A, B, C..." |
I think the current design moves some of the heavy lifting onto
|
In general I'm always eager to push more complexity into wit-parser so it doesn't reside externally in bindings generators, I agree it's best to centralize complexity where possible. For the For fusing things into a single instance that's definitely a well-known complexity of wit-parser. It's not just causing headaches for wit-bindgen-go but all other bindings generators too. That though I think is orthogonal from this issue? |
Agreed the problems are orthogonal! Can name field be consistent with world key in all cases? |
My original proposal was to define the name field of a interface to reflect their fully qualified names, like This actually alignes nicely with the generated Rust namespaces. One is Do you think there are any corner cases where this does not cover? |
For this WIT, what would the fully-qualified WIT identifier be for the inline exported package example:name;
interface exports {
foo: func();
}
world only-exports {
export example:name/exports;
export exports: interface {
foo: func();
}
}
|
I think for WIT as-of today this can be done, but I'm less certain about the WIT-of-tomorrow. One thing we've talked about is having, for example, just a bare Mostly I'm hesitant to couple this too much together. Is it possible for the Go generator to thread the Another alternative though would be to introduce a second key in
For future-compat reasons above I'm hesitant to repurpose
In Rust and C a top-level interface or function starts at the root of the bindgen namespace itself. For example in C that would generate I'm not familiar enough with Go to know if this translates well, but does that help answer the question perhaps? The intention is that top-level anonymous keys definitely don't get namespaced under the package name, for example. |
I implemented a fix for this here: https://github.com/bytecodealliance/wasm-tools-go/pull/176 It nests named interfaces imported into or exported from a world under a Go package path for that world. This allows multiple WIT packages/worlds/interfaces to share a source tree without clobbering each other. |
Consider the following WIT file
The
Resolve
representation of the above World will have two interfaces, one withname: Some("exports")
and the other withname: None
, but it left some ambiguity on how to interpret the name of the second "annonymous" interface. For example, inwit-bindgen
, the interpretation of the name of the seond interface is the World's key name, namely"exports"
.I am proposing to change the type of
Interface::name
fromOption<String>
toString
, and should use the correct naming mechanism so that tools likewit-bindgen
orwit-bindgen-go
do not have to guess what interface names are in case when they are inlinedly defined.The first export's name should be
"example:name/exports"
, and the second export's name should be"exports"
, so that there is no colliding. It also matches the definition in the component model spec.For reference, this is the
wat
representation of the above WITDiscussion
In addition to the proposal, I found that it's a bit strange that I can't reference the first export using a fully qualified name like the one below:
wasm-tools will throw an error saying
I realized this is, by design, prohibited, but I have to admit that it striked me as a surprise.
CC @alexcrichton
The text was updated successfully, but these errors were encountered: