You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some thoughts on this, from discussions at Wasmcon, and my work on the Go bindings generator:
Worlds vs Interfaces
We need to clarify if a Go program will presume an entire WASI world, or can link to individual packages or interfaces.
For example, will a Go program require the host implement the wasi:clicommand world? Or be able to link to and use its constituent parts, e.g. wasi:clocks/monotonic, or wasi:random?
Names
As @Mossaka and others have pointed out, the current names generated by wit-bindgen can be long and cumbersome. I think it makes sense to map the WASI package name + interface into a Go package path, e.g.:
Therefore the type wasi:clocks/monotonic-clock.instant would map to the Go type <prefix>/wasi/clocks/monotonic-clock.Instant.
Second, I think it makes sense to introduce a mapping of WASI names to Go names. This could be specified as command-line arguments to the Go code generator, or loaded from a config file. For example:
wasi:clocks/monotonic-clock → <prefix>/wasi/clocks/monotonic (omitting the -clock suffix)
wasi:clocks/wall-clock.datetime → <prefix>/wasi/clocks/wall.DateTime (explicitly naming a type)
Package path mapping would allow generated code to be placed in an internal directory, so the package author has control over the exported interface, say mapping WASI semantics to Go semantics (e.g. net/http interfaces). This would have the advantage of allowing the Go code generation to iterate without breaking external compatibility for dependent packages.
Stdlib
@achille-roussel pointed out that the requirements for codegen in the Go stdlib may differ materially, such as the number and names of generated Go packages, and how to make tradeoffs between simple vs clever or idiomatic vs performant.
This issue is created for a discussion on improving how types, function and package named in the Go bindgen.
To see how the current names is generated, please read the head of this #612 (comment).
A summary of what's being proposed: #612 (comment)
The text was updated successfully, but these errors were encountered: