Stream: general

Topic: When to use inline functions in a world in Wit?


view this post on Zulip Michael Fuller (Nov 26 2023 at 10:16):

Besides interfaces, a world can contain inline functions. What's the use case for this?

The docs[^1][^2] specifically mention that such a component can't be composed with other components, only if the world contains only interfaces.

[^1]: "to use your component from another component, it must export an interface." source

[^2]: "The component's world (.wit file) must export an interface. (Do not export functions directly, only interfaces.)" source

view this post on Zulip Ramon Klass (Nov 26 2023 at 14:43):

my observation as a user was that "export and import functions" was the default about a year or so ago when I started toying with wit, but the closer we got to preview2, the more problems arose with directly exported functions and it feels like they should be deprecated soon. I don't know if that's correct, as I said that's what I experienced from the outside

view this post on Zulip Alex Crichton (Nov 27 2023 at 04:05):

The use case depends on the world in question, mostly the perspective from an embedding. For example it might be a good model for what the host wants to give a component or what the host would require from a component.

The limitations in the documentation refer to conventions around the wasm-tools compose subcommand. That's not a limitation of components or component runtimes in general, so it might be something worth clarifying in the documentation but I wouldn't say for sure without reading more closely


Last updated: Dec 23 2024 at 12:05 UTC