Skip to content

Commit e747706

Browse files
Merge pull request #177 from itowlson/actually-composing-functions-is-fine-too
Remove claim that composition requires interfaces not functions
2 parents 088fe2a + b229be7 commit e747706

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

component-model/src/creating-and-consuming/running.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ wasmtime run <path-to-wasm-file>
1616

1717
If you're writing a library-style component - that is, one that exports a custom API - then you can run it in `wasmtime` by writing a "command" component that imports and invokes your custom API. By [composing](./composing.md) the command and the library, you can exercise the library in `wasmtime`.
1818

19-
1. Write your library component. The component's world (`.wit` file) must export an interface. (Do not export functions directly, only interfaces.) See the [language support guide](../language-support.md) for how to implement an export.
19+
1. Write your library component. The component's world (`.wit` file) must export an interface and/or one or more functions through which a consumer can call it. See the [language support guide](../language-support.md) for how to implement an export.
2020

2121
2. Build your library component to a `.wasm` file.
2222

23-
3. Write your command component. The component's world (`.wit` file) must import the interface exported from the library. Write the command to call the library's API. See the [language support guide](../language-support.md) for how to call an imported interface.
23+
3. Write your command component. The component's world (`.wit` file) must import the interface or functions exported from the library. Write the command to call the library's API. See the [language support guide](../language-support.md) for how to call an imported interface.
2424

2525
4. Build your command component to a `.wasm` file. You will not be able to run this in `wasmtime` yet, as its imports are not yet satisfied.
2626

component-model/src/language-support/csharp.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ The component will be available at `bin/Debug/net9.0/wasi-wasm/native/adder.wasm
111111

112112
## Building a component that exports an interface
113113

114-
The previous example uses a WIT file that exports a function. However, to use your component from
115-
another component, it must export an interface. That being said, you rarely find WIT that does not
116-
contain an interface. (Most WITs you'll see in the wild do use interfaces; we've been simplifying by
117-
exporting a function.) Let's expand our `example` world to export an interface rather than directly
114+
The previous example uses a WIT file that exports a function. However, you'll often prefer to export an interface,
115+
either to comply with an existing specification or to capture a set of functions and types that tend to go
116+
together. Let's expand our `example` world to export an interface rather than directly
118117
export the function. We are also adding the `hostapp` world to our WIT file which we will implement
119118
in [the next section](#building-a-component-that-imports-an-interface) to demonstrate how to build a
120119
component that *imports* an interface.

component-model/src/language-support/python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ See [`componentize-py`'s examples](https://github.com/bytecodealliance/component
6262

6363
### Building a Component that Exports an Interface
6464

65-
The [sample `add.wit` file](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host/add.wit) exports a function. However, to use your component from another component, it must export an interface. That being said, you rarely find WIT that does not contain an interface. (Most WITs you'll see in the wild do use interfaces; we've been simplifying by exporting a function.) Let's expand our example world to export an interface rather than directly export the function.
65+
The [sample `add.wit` file](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host/add.wit) exports a function. However, you'll often prefer to export an interface, either to comply with an existing specification or to capture a set of functions and types that tend to go together. Let's expand our example world to export an interface rather than directly export the function.
6666

6767
```wit
6868
// add-interface.wit

component-model/src/language-support/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ $ cargo run --release -- 1 2 ../add/target/wasm32-wasip1/release/add.wasm
8181

8282
## Exporting an interface with `cargo component`
8383

84-
The [sample `add.wit` file](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host/add.wit) exports a function. However, to use your component from another component, it must export an interface. This results in slightly fiddlier bindings. For example, to implement the following world:
84+
The [sample `add.wit` file](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host/add.wit) exports a function. However, you'll often prefer to export an interface, either to comply with an existing specification or to capture a set of functions and types that tend to go together. For example, to implement the following world:
8585

8686
```wit
8787
package docs:[email protected];

0 commit comments

Comments
 (0)