From b229be7104a367166a9f3bcbdc6e171661146886 Mon Sep 17 00:00:00 2001 From: itowlson Date: Fri, 22 Nov 2024 14:46:30 +1300 Subject: [PATCH] Remove claim that composition requires interfaces not functions Signed-off-by: itowlson --- component-model/src/creating-and-consuming/running.md | 4 ++-- component-model/src/language-support/csharp.md | 7 +++---- component-model/src/language-support/python.md | 2 +- component-model/src/language-support/rust.md | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/component-model/src/creating-and-consuming/running.md b/component-model/src/creating-and-consuming/running.md index 63b6c714..a76398b6 100644 --- a/component-model/src/creating-and-consuming/running.md +++ b/component-model/src/creating-and-consuming/running.md @@ -16,11 +16,11 @@ wasmtime run 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`. -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. +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. 2. Build your library component to a `.wasm` file. -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. +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. 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. diff --git a/component-model/src/language-support/csharp.md b/component-model/src/language-support/csharp.md index 972e1b55..925022e7 100644 --- a/component-model/src/language-support/csharp.md +++ b/component-model/src/language-support/csharp.md @@ -111,10 +111,9 @@ The component will be available at `bin/Debug/net9.0/wasi-wasm/native/adder.wasm ## Building a component that exports an interface -The previous example uses a WIT file that 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 +The previous example uses a WIT file that 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. We are also adding the `hostapp` world to our WIT file which we will implement in [the next section](#building-a-component-that-imports-an-interface) to demonstrate how to build a component that *imports* an interface. diff --git a/component-model/src/language-support/python.md b/component-model/src/language-support/python.md index b1652baf..a9a925f8 100644 --- a/component-model/src/language-support/python.md +++ b/component-model/src/language-support/python.md @@ -62,7 +62,7 @@ See [`componentize-py`'s examples](https://github.com/bytecodealliance/component ### Building a Component that Exports an Interface -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. +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. ```wit // add-interface.wit diff --git a/component-model/src/language-support/rust.md b/component-model/src/language-support/rust.md index a6aa26b6..057c5f26 100644 --- a/component-model/src/language-support/rust.md +++ b/component-model/src/language-support/rust.md @@ -81,7 +81,7 @@ $ cargo run --release -- 1 2 ../add/target/wasm32-wasip1/release/add.wasm ## Exporting an interface with `cargo component` -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: +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: ```wit package docs:adder@0.1.0;