The wit documentation defines the resource
item but this appears to be removed from wit-bindgen
. What is the status of this?
The status is that resources are a very important feature but are not yet described by the component-model spec. wit-bindgen had a prototype implementation, but it's been removed in order to simplify other component implementation work, and because the semantics of handles are expected to be a little different from what was prototyped.
Luke and others are actively working on the new resource+handle design in the component model, as it's a high priority for a lot of use cases.
@Dan Gohman Is the expectation to install wit-bindgen
from git?
Yes
Intentionally (I think) not on crates.io because of how unstable it is known to be
@Alex Crichton I see that world file syntax has landed. Can you give me a pointer to the documentation for that syntax?
I found this: https://github.com/WebAssembly/component-model/blob/8a5669d4b6e534f3cd70a4b90f482ab94e4e891d/design/mvp/WIT.md#item-world
But that document still has resources, etc in the syntax.
I'd recommend reading tests and such for now, it's not documented yet
Has the use
keyword been removed?
yes, as part of the implementation of parsing worlds; much like resource, it was removed in anticipation of doing it "for real" with a proper spec
Is it possible to use a type defined in one interface in another interface?
With use
being temporarily removed, no, you'll need to copy/paste
It's expected to not take too long before re-adding use
Does use
also export the values specified by use
?
Sorry I don't know how best to answer that since use
isn't currently implemented
@Alex Crichton I'm implementing it now. So I'm asking what the preferred implementation should be. Sorry for lack of clarity.
Have you talked with Luke or Brian or others? There's a number of design questions about use
which are unresolved which were why the initial implementation was removed and deferred temporarily.
Nope. But I'm happy to chat.
@Alex Crichton Which Brian?
this one -- https://github.com/fibonacci1729/
:wave: Hey Nathaniel, happy to chat
I think we'll try to meet next week once everyone's back to talk about things, ahead of time I do not personally have a complete picture of what use
should look like
@Luke Wagner ?
@Luke Wagner Are you available?
@Brian Available now?
I'll be available at the top of the hour
@Alex Crichton @Luke Wagner @Brian https://meet.google.com/kjj-rqog-kni
sorry I'm not personally available to meet about this today, but y'all are of course welcome to
No worries. I think I have enough to go on given my reading of the AST.
I'm happy to jump in now or later.
Just chatted with Nathaniel and he is working to re-add use
to enable sharing types between interfaces defined in the same *.wit
file, improving the usability of *.wit
today. This makes sense to me since most of the design questions around use
arise from wits that are spread across multiple files.
@Brian Having now torn a bunch of this apart, I think defaulting to "private" imports doesn't really make sense. You basically only import types for the purposes of re-exporting them OR using them as params/results for functions. In the later case, the types must be public otherwise the functions aren't callable.
@Nathaniel McCallum So instead of what we discussed (i.e. re-exporting via a type alias),
are you suggesting something like:
interface a {
type x = string
}
interface b {
use { x } from a
}
interface c {
use { x } from b
}
@Brian Yes, precisely.
Hi! Apologies for resurrecting this thread, but I was wondering if there had been any progress on same-file type sharing between interfaces. I'd like to share types between my imports and exports, but I'm guessing this isn't supported yet: error: expected
type or
func, found keyword
use` for a
use * from common in the
interface`.
Will this be implemented soon, and if not, what's the best way to handle type-sharing? (i.e. before updating, I had duplicate types that I had to manually merge together in the host code. Is that still necessary?)
Cheers!
Progress is being made! https://github.com/bytecodealliance/wasm-tools/pull/867
Oh wow, that's awesome, thank you! Looks promising; I'll see if I can postpone this update until that lands.
Last updated: Nov 22 2024 at 16:03 UTC