wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

[Question] `use` semantics with re-exports

Open willemneal opened this issue 4 years ago • 1 comments

From my understanding every type in a .wit file is treated as an export. Using use allows importing types from other files. Like with header files these types can be used before being defined since after loading in all of the types everything is considered one namespace.

When use consuming a wit to say make a markdown file. Should all of the types be included? Since they are part of this namespace are they re-exported?

willemneal avatar Jan 21 '22 15:01 willemneal

Unfortunately I think the answer at this time is somewhat complicated. The theory behind use is that it's not a #include-like system from C where the contents are copy/pasted, but rather more of a module-system-like use-the-definition. In that sense what needs to theoretically happen in the documentation is that a link is generated to somewhere else.

At the lowest layer, though, interface types are structurally typed, not nominally typed, except for resources. In that sense it would make sense to copy over documentation perhaps for everything except the resource types, perhaps indicating that they're referenced from somewhere else.

Overall the use system is still somewhat under-baked and pretty early. Various features you might expect to work likely don't work well or have missing design questions at this point. As it gets more usage over time though we'll likely flesh out these details!

alexcrichton avatar Jan 21 '22 17:01 alexcrichton

I think that this is more-or-less a duplicate of https://github.com/bytecodealliance/wit-bindgen/issues/266 so I'm going to close in favor of that.

alexcrichton avatar Sep 06 '22 18:09 alexcrichton