-
Notifications
You must be signed in to change notification settings - Fork 83
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
Split 'use' inside worlds into 'use import' and 'use export' #308
base: main
Are you sure you want to change the base?
Conversation
Thanks for writing this up! I'd be hesitant to merge this as-is as I suspect it'll take a bit to get this implemented and I'd want to avoid the case where the docs here don't reflect the state of the world. That being said this is probably going to be a common problem, so I feel like we should fix this at some point. I know we have the emoji bits but holding everything up or requiring things purely because of an implementation doesn't feel great. If this isn't where most people come for docs, though, then it's probably ok if the two drift. Given where we are in the proposal though I feel like folks still come here pretty frequently to double-check behaviors and such. From a more bike-sheddy perspective it feels a bit unfortunate that For the syntactic difference we could perhaps have In terms of breakage I don't think we can remove the existing |
Thanks for all the feedback! I'm happy to not merge this PR until the new syntax being proposed has been implemented so that if people see it in WIT.md and then write it using updated release tooling, it works. We could go the emoji-tag route, but seeing as how this isn't a fundamental C-M feature, but rather a WIT syntax change, it feels like maybe we could avoid the overhead. It also makes sense in a transitional time frame to continue to parse and support the existing Regarding the asymmetry between interface i { resource r; }
interface j { use i.{r}; f: func() -> r; }
world w {
import i;
export i;
export j with { i = import i };
} to override what, iirc, is the default behavior that the |
Ok yeah I'm sold on that point, and that sounds good to me. I like the idea of purposing How do you feel about the syntax bikeshed of |
I don't feel super-strongly, but I suppose I still have a preference for
Just sketching an example both ways world w {
import wasi:http/outgoing-handler;
use import wasi:http/types.{request, response};
export frob: func(r: request) -> response;
} vs. world w {
import wasi:http/outgoing-handler;
import use wasi:http/types.{request, response};
export frob: func(r: request) -> response;
} subjectively, the former seems to more clearly explain to me that we're doing 3 distinct things, importing, projecting and then exporting rather than doing 2 imports and 1 export. |
Ok yeah I'm sold on that as well 👍 |
the only thing I'd add after this while, finding this discussion is that it's |
I'm interested in this functionality as it's necessary for some virtualization scenarios I'm working on. I'd be interested in potentially helping implement this in the various tools. However some thoughts/questions: Bikeshedding Looking at the current examples, I'm interested in why the Rewriting the example @lukewagner gave without the world w {
import wasi:http/outgoing-handler;
import wasi:http/types.{request, response};
export frob: func(r: request) -> response;
} In my mind this is also easier to learn as newcomers are not confronted with a new keyword. What does the ** Bikeshedding My use case requires the ability to specify whether a The proposed syntax from @lukewagner seems reasonable: export j with { i = import i }; Though I can imagine a few variants:
Perhaps the
The use of a In any case, @lukewagner did you want to take a stab at writing the grammar for this disambiguation syntax before we start down the path of implementation? |
@rylev Great to hear and great feedback! On first consideration, I really like your proposed alternative to kill |
On second thought, working on the grammar, I think maybe having world w {
...
export wasi:http/types.{request} using { wasi:io/error = my-error };
export foo: interface {
resource res;
foo: func() -> res;
}.{res};
export frob: func(r: res) -> request;
} Although less compact, with a separate world w {
export wasi:http/types using { wasi:io/error = my-error };
export foo: interface {
resource res;
foo: func() -> res;
};
use export foo.{res};
use export wasi:http/types.{request};
export frob: func(r: res) -> request;
} WDYT? |
f61d68b
to
a4dcbe8
Compare
@lukewagner I'm convinced. Your example with |
agree quickly with @rylev here; having the explicit |
OH! one other thing. In past "interface sharing technologies" there was much too and fro about having a shared typelib of interfaces that both sides could reuse; it was the only thing that made "getting it right on the wire" possible for humans. In this case, we're NOT trying to nail the wire protocol down to the bit/endianess, but the general usage problem remains. I see this as paving that path to shared types. If I'm mistaken, def let me know. :-) |
@rylev Ok, cool, I left the |
824fdc5
to
74bd278
Compare
This PR proposes to change how
use
works inside WITworld
s, based on some initial discussion in wit-bindgen/#822.Currently,
use
can be used with the same syntax in bothinterface
s andworld
s. Forinterface
s, the syntax works great, but in aworld
context, it's rather ambiguous whether ause
refers to imports or exports (and when interfaces are implicitly pulled in, whether they are pulled in as imports or exports). Furthermore, in the advanced case where you want to both import and export the same interface and be able to refer to both imported and exported versions of a type defined in that interface, it's not possible. (It is expressible in Component Model WAT, though.)This PR avoids the ambiguity and removes the expressivity gap by removing the plain
use x
syntax from worlds and, in its place, addinguse import x
anduse export x
. See the PR for an example.This change is only at the WIT-level; Component Model WAT can already express both of these more-explicit versions of
use
(viaalias
definitions). I'm not aware of any WASI WIT that actually usesuse
in aworld
, so this doesn't affect the literal WIT stabilized in 0.2, which is nice. It might break some handwrittenworld
s though (see the abovementioned wit-bindgen issue), so perhaps we could support (but warn for) the existinguse
-in-world
s syntax for a period of time.