Consistent version syntax
Currently, WIT package names put the version after the package name:
package wasi:[email protected];
However, WIT use statements and similar things put the version after the interface:
use wasi:http/[email protected].{incoming-request};
Similarly, import/export strings also put the version after the interface:
(import "wasi:http/[email protected]" (instance (;0;) (type 0)))
These lead me to sometimes be confused about whether to say wasi:[email protected]/types.{incoming-request} or wasi:http/[email protected].{incoming-request}. I've been trying to get used to it by telling myself that package wasi:[email protected]; is syntax-sugar for adding the version explicitly to all of the contained interfaces, but I still get confused. It doesn't help that interface [email protected] { isn't valid in WIT, and I don't expect it ever will be.
And, wasi:http/[email protected].{incoming-request} suggests a misleading mental model, as if wasi:http were a thing that gets looked up without a version, and then [email protected] is a versioned thing to look up inside that.
Additionally, [email protected].{incoming-request} is awkward with a . immediately after the .-separated semver syntax, looking to a first glance like it might be part of the version.
I propose changing WIT and components to use the wasi:[email protected]/types.{incoming-request} form, pre-1.0 when we have an opportunity to make a breaking change.
That's a good point and I've wondered whether we should do that too. I'd be open to the change and it does seems like a good thing to discuss including as part of the 1.0 binary format breaking changes.
This always felt off to me as well, but I couldn't articulate why quite as clearly as laid out here—thank you for that!
To enable adoption of the proposed format, would it be possible to support both, and then eventually deprecate the current format? We could then disallow it for at least WASI interfaces with versions >= 1. (We could consider disallowing it for all interfaces with versions >= 1, but that'd certainly break some existing uses, so would at least need more care.)
I think this touches the same underlying problem of https://github.com/WebAssembly/component-model/issues/231, albeit with a different proposed solution.
One issue is that the use syntax uses the . separator, and at the same time also defers to the semver standard for the version number format. But semver also has its own (different!) meaning for .
An example from https://github.com/WebAssembly/component-model/issues/231:
use example:http/[email protected].{ request, response }
// It may look like we're "drilling into" some sort of `nginx` submodule
// of the `example:http/[email protected]` package, but actually `nginx` is part of the
// semver 'prerelease' component.
lol. I thought I was the only one confused with the syntax. 😆
When I saw package wasi:[email protected];, I thought I need to write import "wasi:[email protected]/types".
But I turned out to be import "wasi:http/[email protected]".
That was unexpected. Hope this get changed.