Determine the use of implicit or explicit external import module names. In wasm, a module declares the namespace or library name a function belongs to when importing the function from the host. Currently, there is some non-standard use of module namespaces unless overriding it explicitly within a module.
Having picked env
for convenience (and possible lack of support for alternatives), we now need to pick a more specialized name to maintain compatibility
across different types of WebAssembly applications.
It now makes sense to use extism:host/env
- a component-model friendly, namespace for Extism host functions. User-defined host functions will be defined in the
extism:host/user
namespace by default, but this can be configured.
When targeting wasm, a language would need to have built-in support to declare the namespace an external function comes from.
Here's a tracking table for the languages we want to support and a reference to their library / module name override implementation:
Language support for module namespace declaration:
It does not appear that all languages use the same default namespace, should one not be specified.
E.g. Rust uses env
, AssemblyScript uses import
.
There are benefits to using an explicit namespace in this context, such as the ability to immediately diagnose that a function is expected to
come from our runtime. This is useful when debugging a module and seeing clearly that there are functions used from Extism. Or if there are other
functions expected, which are not within the extism:host/env
namespace, it becomes easier to pinpoint the issue and propose a fix.
Additionally, we can avoid symbol collisions or shadowing if there is ever support for module linking or something like the component model. Ideally, we don't restrict the use of or conflict with other namespaced functions.