-
Notifications
You must be signed in to change notification settings - Fork 79
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 Syntax: world
#83
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'm excited for world files!
3e6979b
to
9cc16f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's a draft, but here are a few high-level suggestions:
I've talked with @fibonacci1729 a bit about this but I wanted to write something down here as well to make it more broadly known. Personally I think it would be best to not have what feels like "yet another text format" with the component model and figure out a way to fit this into existing constructs, e.g.
To be clear my concerns are at the syntactic and organization layer. The capabilities and conceps expressed in I've been hesitant to write any of this down without any actual suggestion of something else to do, and while I have some small inspiration it still doesn't feel great. A rough idea of how we could shoehorn this is to merge the syntaxes of world and wit files and have both a top-level and and interface parsing context. For example:
This solves the two issues I brought up by (a) merging the two syntaxes so there's only one "thing" to talk about, albeit the "thing" is the sum of the two prior sizes so it's only less complicated subjectively I think because there's not "world or wit" it's just all wit. And (b) with merged syntaxes it's possible to have everything inline in one file for tests/sharing/etc where it probably wouldn't be the idiomatic organization that everyone uses but I think would still be useful to have. My thinking is that the strings referring to other interfaces are looked up locally within the file first (e.g. prior I don't think this is the complete picture though because if you try to define |
Great points and ideas. First, I definitely agree we should allow for having all-in-one files that contain all relevant definitions. Initially I had been thinking of starting with World files only containing references to Wit files via URL as an incremental baby step towards Worlds (which also matches what I think we'd want to standardize in a WASI context), but that does neglect the testing use case you brought up which does seem like a near-term necessity, so I think it makes sense to eagerly include inline definitions, including As for whether we should:
I'm not sure yet. It seems like there are still some details to figure out for 1, as you pointed out so I'm interested to discuss this more. One thing thinking about this has helped me realize is that I've been saying "wit" to mean "the syntax for defining an interface" mostly just because that's what it has meant for a while. But once you have two kinds of definitions, "interface" and "world", it does feel natural from first principles to have a single term (such as "wit") referring to "the whole IDL". So I think that is also a part of this choice between 1 and 2: whether "wit" is associated with "interfaces" or whether "wit" means "the whole IDL". In any case, I do really like the term "world" meaning "a set of imports and exports". Previously we called it a "profile", but that doesn't seem to resonate with folks the way I initially thought it would; whereas "world" does (credit to Dan for suggesting the term). So whether it's in the filename extension and/or inline in the text as a keyword, I'd love to keep |
Thinking about this a bit more, the idea of saying that there is a single "Wit" syntax containing both interface and world definitions has grown on me. So, riffing on what Alex wrote above to try to answer the question he asked at the end: what if the rule was, if you have a file So then I could write:
OR, I could write:
noting that the top-level Earlier, I suggested removing the Lastly, the URLs written in my example only parse as URLs if there is a base URL supplied to the URL parser. It seems like it might be useful to allow this base URL to be an explicit parameter to tools like wit-bindgen so that the Wit files can be written as above in a base-URL-agnostic manner so that they can be, e.g., referenced both as standards with a Thoughts? |
I love the direction we are going with! @alexcrichton's concerns are valid and resonate with me. I like the idea that "wit" refers to "the whole IDL", while "world" refers a set of imports and exports. When
Note that the last two import and export are top-level world definition. The Furthermore, since the top level is a world, which contains inline sub-world definitions. This seems like we are allowed to have nested world declarations.
This starts to look very similar to the module system in programming languages like Rust. |
@Mossaka Great comments, thanks. Yes, I think we should be able to both have multiple If we go with a single Wit format (with a single
or
? And agreed, it is rather module-system-ish :) |
How do "worlds" & "interfaces" relate to components? During the 22 Sept. WASI meeting @fibonacci1729 provided a brief answer. However, I didn't quite understand. 😅 Would you mind explaining here? Also, if I recall correctly, "worlds" are supposed to give an extra layer of abstraction over components. How so? |
Probably your comment is directed at including an answer in the document, not just the comments, but just to answer here briefly, from a component-model AST POV:
Thus, given any component |
8f3228d
to
eff9513
Compare
eff9513
to
3ec91e4
Compare
I updated the document to reflect the above Let me know if I missed anything or didn't capture something correctly! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for incorporating the comments! Just to see if I'm understanding the next steps for this PR correctly, is the idea to:
- Update
WIT.md
in-place as proposed in WIT Syntax:interface
#115 - Rebase this PR on top of that, ultimately adding
world
definitions toWIT.md
instead of making a newWORLD.md
?
Is that right? And, just to double-check: are you also planning to create (1) or were you hoping someone else would? Thanks!
@lukewagner That is the plan! I'm planning to push the PR for (1) today or tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updated PR @fibonacci1729 . It's looking great~
One thing I think would be good to specify in the In the
That at least is the current expressiveness of |
3ec91e4
to
dfb3113
Compare
This is probably out of scope for this design, but I'd like to discuss about worlds unions and intersections and how subtyping works in this regard. I am working on the wasi-kv-store proposal and started to use the new I have the following design for a key-value store world, and a cloud/service world, which imports the former one. world "wasi:cloud/services" {
import kv: {*: "wasi:cloud/kv"}
import mq: {*: "wasi:cloud/mq"}
...
export http: "wasi:http/handler"
}
world "wasi:cloud/kv" {
import kv: {*: "wasi:kv/data/crud"}
export http: "wasi:http/handler"
} I assume that Things become less clear to me is how world union works. For example, if I have a kv world that expects some advanced features like As a side note: I notice that optional imports/exports are out of scope for components MVP, but I am thinking that the kv-store could be a great example of exposing a world with optional imports that capture advance use cases. |
@Mossaka Here's a first stab at an answer but maybe we should move any follow-up discussion to a new issue so we can dig in. If I understand your scenario correctly, the union of the simple and advanced kv-store worlds would offer both interfaces. Despite them both being logically "kv stores", the two interfaces would by default be as separate as any two other interfaces, and thus if a component imported both, it would have two instance imports (one implementing the simple kv-store interface, one implementing the advanced kv-store interface) each named by their distinct |
This PR sketches out the initial format for WebAssembly profiles, i.e. world files. Signed-off-by: Brian H <brian.hardock@fermyon.com>
fe49b32
to
8a5669d
Compare
I was reading over this again just now, as of right now the differences with what's implemented in
I wanted to write this down to pose the question how best to resolve this. The as-documented-right-now-in-this-PR semantics don't support the use case of "export directly from the component an Do others have ideas of how to resolve this? |
Could we allow world imports and exports to have inline function (and later potentially other) types, e.g.: world my-world {
import fs: "wasi:filesystem"
import foo: func(x: string) -> string
export handler: "wasi:http/handler"
export bar: func(x: string) -> string
export baz: func() -> u32
} with the compiled component type being: (component
(import "fs" "wasi:filesystem" (instance ...))
(import "foo" (func (param "x" string) (result string)))
(export "handler" "wasi:http/handler" (instance ...))
(export "bar" (func (param "x" string) (result string)))
(export "baz" (func (result u32)))
) ? |
That's what specified here in this PR believe, but the feature of
where the component to generate is: (component
(export "foo" (func))
) where the interface Is this a feature worth supporting though? Should support for this just be dropped from |
Oh, sorry, I misunderstood. I would guess "no" and if we decide we need it in the future, it would be some new keyword specifically for "splatting" interfaces. |
I may have missed or forgotten something, but is this otherwise ready to go? I created bytecodealliance/wasm-tools#859 to remove support for |
@alexcrichton I'll rebase this onto #141, does that sound good? |
Happy to go either way myself! |
SGTM! Let's merge this and handle the inconsistent deltas in your PR (which as far i can tell addresses most of them anyway). |
This PR updates WIT to include the syntax for Worlds.
Signed-off-by: Brian H brian.hardock@fermyon.com