Skip to content

Commit 3228cb2

Browse files
Merge pull request #204 from pedromsrocha/patch-1
reorganize tutorial and remove redundant info
2 parents 4be8b19 + 8527c6f commit 3228cb2

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

component-model/src/tutorial.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ Wasm components, we will compose them into a single runnable component, and test
1616
## The calculator interface
1717

1818
For tutorial purposes, we are going to put our "calculator engine" and "addition operation" interfaces into two separate WIT packages, each containing one WIT file. This may seem excessive, but the reason is to illustrate real-world use cases where components come from different authors and packages.
19-
These files can be found in the component book repository in the [`wit` directory](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/tutorial/wit) under `wit/adder/world.wit` and `wit/calculator/world.wit`. These files define:
20-
21-
* A world describing an world that exports the "add" interface. Again, components such as the calculator can call it when
22-
they need to add numbers.
23-
19+
These files can be found in the component book repository in the [`wit` directory](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/tutorial/wit) under `wit/adder/world.wit` and `wit/calculator/world.wit`:
2420
```wit
2521
// wit/adder/world.wit
2622
package docs:[email protected];
@@ -32,23 +28,7 @@ These files can be found in the component book repository in the [`wit` director
3228
world adder {
3329
export add;
3430
}
35-
```
36-
37-
* An interface for the calculator itself. We'll use this later to carry out calculations. It
38-
contains an evaluate function, and an enum that delineates the operations that can be involved in
39-
a calculation. In this tutorial, the only operation is `add`.
40-
* Interfaces for the various operations the calculator might need to carry out as part of a
41-
calculation. For the tutorial, again, the only import we define is for the "add" operation from
42-
the "docs:adder" world defined previously.
43-
* A world describing the calculator component. This world exports the calculator interface, meaning
44-
that other components can call it to perform calculations. It imports the operation interfaces
45-
(such as "add"), meaning it relies on other components to perform those operations.
46-
* A world describing the "primary" app component, which imports the "calculate" interface. This is
47-
the component will take in command line arguments and pass them to the "eval-expression" function
48-
of the calculator component.
4931
50-
51-
```wit
5232
// wit/calculator/world.wit
5333
package docs:[email protected];
5434
@@ -70,6 +50,19 @@ These files can be found in the component book repository in the [`wit` director
7050
7151
```
7252

53+
These files define:
54+
* A world `adder` that exports the `add` interface. Again, components such as the calculator can call it when
55+
they need to add numbers.
56+
* A world `calculator` describing the calculator component. This world exports the calculator interface, meaning
57+
that other components can call it to perform calculations. It imports the operation interfaces
58+
(such as `add`), meaning it relies on other components to perform those operations.
59+
* An interface `calculate` that contains an evaluate function and an enum that delineates
60+
the operations that can be involved in a calculation. In this tutorial, the only operation is `add`.
61+
* A world `app` describing the "primary" app component, which imports the `calculate` interface.
62+
This component will take in command line arguments and pass them to the `eval-expression` function
63+
of the calculator component.
64+
65+
7366
## Create an `add` component
7467

7568
Reference the [language guide](language-support.md) and [authoring components

0 commit comments

Comments
 (0)