Skip to content

[witx] Make use import individual names from other modules #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sunfishcode opened this issue Jan 26, 2021 · 0 comments · Fixed by #415
Closed

[witx] Make use import individual names from other modules #378

sunfishcode opened this issue Jan 26, 2021 · 0 comments · Fixed by #415

Comments

@sunfishcode
Copy link
Member

Witx's current mechanism for supporting declarations across multiple files is use which imports the contents of one file into another. This was a simple way to get witx started, however it isn't amenable to splitting up WASI into multiple modules.

A better approach would be to have use work more like a proper module system in high-level programming languages, where one can use specific items from other modules.

So instead of

(use "typenames.witx")

We should have something like

(use $timestamp from $wasi_filesystem)

where $wasi_filesystem is a module which defines a $timestamp` type.

@linclark linclark added this to the WASI Modularization milestone Jan 26, 2021
alexcrichton added a commit to alexcrichton/WASI that referenced this issue Mar 22, 2021
This commit implements a new `use` syntax which changes

  (use "foo.witx")

to

  (use $some $type $names from $foo)

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:

* The `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.
* The `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.
* The `representation` module was removed since it was largely only used
  by the `polyfill` module.
* The `Document` type was renamed to `Module`, 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 that
  `Module` is now a list of types and a list of functions.
* Documentation has changed to document a set of modules instead of a
  single module. Additionally this is nontrivially changed to load types
  transitively from all modules referenced to ensure that all relevant
  types are documented.
* Internal refactorings in the validation phase have been done to
  streamline a few things and consolidate where possible with this new
  structuring.
* `InterfaceFunc` is now named `Function`
* `InterfaceFuncParam` is now named `Param`
* `Module` has a `name` (as before) which is now inferred from the
  filename it's loaded from.
* `Module` has a `ModuleId` now to represent types that are defined in
  other modules, where `ModuleId` 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 WebAssembly#378
Closes WebAssembly#379
alexcrichton added a commit to alexcrichton/WASI that referenced this issue Mar 29, 2021
This commit implements a new `use` syntax which changes

  (use "foo.witx")

to

  (use $some $type $names from $foo)

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:

* The `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.
* The `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.
* The `representation` module was removed since it was largely only used
  by the `polyfill` module.
* The `Document` type was renamed to `Module`, 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 that
  `Module` is now a list of types and a list of functions.
* Documentation has changed to document a set of modules instead of a
  single module. Additionally this is nontrivially changed to load types
  transitively from all modules referenced to ensure that all relevant
  types are documented.
* Internal refactorings in the validation phase have been done to
  streamline a few things and consolidate where possible with this new
  structuring.
* `InterfaceFunc` is now named `Function`
* `InterfaceFuncParam` is now named `Param`
* `Module` has a `name` (as before) which is now inferred from the
  filename it's loaded from.
* `Module` has a `ModuleId` now to represent types that are defined in
  other modules, where `ModuleId` 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 WebAssembly#378
Closes WebAssembly#379
alexcrichton added a commit to alexcrichton/WASI that referenced this issue Mar 29, 2021
This commit implements a new `use` syntax which changes

  (use "foo.witx")

to

  (use $some $type $names from $foo)

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:

* The `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.
* The `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.
* The `representation` module was removed since it was largely only used
  by the `polyfill` module.
* The `Document` type was renamed to `Module`, 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 that
  `Module` is now a list of types and a list of functions.
* Documentation has changed to document a set of modules instead of a
  single module. Additionally this is nontrivially changed to load types
  transitively from all modules referenced to ensure that all relevant
  types are documented.
* Internal refactorings in the validation phase have been done to
  streamline a few things and consolidate where possible with this new
  structuring.
* `InterfaceFunc` is now named `Function`
* `InterfaceFuncParam` is now named `Param`
* `Module` has a `name` (as before) which is now inferred from the
  filename it's loaded from.
* `Module` has a `ModuleId` now to represent types that are defined in
  other modules, where `ModuleId` 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 WebAssembly#378
Closes WebAssembly#379
sunfishcode pushed a commit that referenced this issue Mar 29, 2021
This commit implements a new `use` syntax which changes

  (use "foo.witx")

to

  (use $some $type $names from $foo)

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:

* The `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.
* The `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.
* The `representation` module was removed since it was largely only used
  by the `polyfill` module.
* The `Document` type was renamed to `Module`, 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 that
  `Module` is now a list of types and a list of functions.
* Documentation has changed to document a set of modules instead of a
  single module. Additionally this is nontrivially changed to load types
  transitively from all modules referenced to ensure that all relevant
  types are documented.
* Internal refactorings in the validation phase have been done to
  streamline a few things and consolidate where possible with this new
  structuring.
* `InterfaceFunc` is now named `Function`
* `InterfaceFuncParam` is now named `Param`
* `Module` has a `name` (as before) which is now inferred from the
  filename it's loaded from.
* `Module` has a `ModuleId` now to represent types that are defined in
  other modules, where `ModuleId` 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants