Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bundled examples

简体中文

The compiler repository includes four small packages. Install pud first, then clone the compiler repository. The commands below run from the repository root.

PackageWhat it demonstratesCommand
todoRead data from JSON and handle errorscd examples/todo then pud run
wordfreqRead standard input and count tokens with a mapprintf 'a b a\n' | pud run examples/wordfreq
pluginImplement exports for a custom WIT worldpud build examples/plugin --target plugin
plugin-hostUse several host capabilities in one componentpud build examples/plugin-host --target plugin

todo reads todos.json from the current working directory and reports 2 of 4 left. wordfreq prints two lines, with count 2 for a and count 1 for b. The plugin builds produce target/plugin/plug.wasm and target/plugin/plugin-host.wasm under their respective package directories.

For a plugin invocation you can reproduce end to end, follow Plugins. The greet export in the plugin example calls the custom demo:host/log interface, which the embedded runner cannot provide. The classify export does not call that interface.