Closed alexcrichton closed 3 years ago
feel free to ignore, but it would be nice if something delineated the list of import names. maybe an extra pair of parens?
Overall this looks good! My biggest concern here is the removal of the top-level (module
)
syntax. For what it's worth I proposed a simlar syntax change back when the original wat syntax was being designed and it was clear that we wanted a file format fold holding exactly-one-module. But now, with witx being derived from wat syntax, and wat syntax retaining the outer (module
)
around it, it feels like witx should retain it too.
Isn't the outer (module ..)
syntax optional in the .wit
format?
I am not personally wed to any particular syntax here, so I'm happy to tweak as necessary for imports/etc.
@sunfishcode are you ok with the one-module-per-text-file restriction? (same as *.wat
) It sounds like the module
wrapper would be purely syntactical but wanted to confirm.
It's also true yeah that at least in *.wat
the (module ...)
is optional but AFAIK almost no one omits it, so seems reasonable to start requiring (module
here and it can always be relaxed in the future.
One-module-per-file is ok with me. Hmm, I actually forgot that (module ...)
is optional; it's not optional in the spec, and all the official examples include it, and it does seem everyone use it includes it in practice.
I think my instinct is that we should support and require the (module ...)
at this point, though I could be convinced otherwise.
Ok updated!
This commit implements a new
use
syntax which changesto
This change ended up being much larger than originally intended. While at a surface level switching this style of
use
statements isn't too bad it has large ramifications on the mental model of how to interpret and work with*.witx
files. This necessitated some internal refactorings which ended up as a bit of a yak shave. The other changes here are:polyfill
module is removed. I confirmed with Pat that this isn't used anymore and this came about trying to update it from the below refactorings.render
module is removed. Documents can no longer be serialized to a standalone s-expression because they can refer to other documents in a structured manner. It's also believed there are no current users of this functionality.representation
module was removed since it was largely only used by thepolyfill
module.Document
type was renamed toModule
, and the ability for a document to contain multiple modules has been removed. When working with multiple modules this must now be done so explicitly instead of having it all lumped into one parsed object. This means thatModule
is now a list of types and a list of functions.InterfaceFunc
is now namedFunction
InterfaceFuncParam
is now namedParam
Module
has aname
(as before) which is now inferred from the filename it's loaded from.Module
has aModuleId
now to represent types that are defined in other modules, whereModuleId
is intended to be a unique identifier amongst a set of modules. For now it's just a path name but can likely get more fancy in the future if needed.All
*.witx
files have been updated to the new syntax in this repository. Lots of changes look like they happened to the proposal documentation, but that's just because the documentation order of types has been shuffled around. I've checked to make sure no actual items were lost from the documentation.Closes #378 Closes #379