diff --git a/doc/src/language/fn-namespaces.md b/doc/src/language/fn-namespaces.md index 27f005c3..0621472f 100644 --- a/doc/src/language/fn-namespaces.md +++ b/doc/src/language/fn-namespaces.md @@ -10,7 +10,7 @@ Each Function is a Separate Compilation Unit This means that individual functions can be separated, exported, re-grouped, imported, and generally mix-'n-match-ed with other completely unrelated scripts. -For example, the `AST::merge` method allows Global all functions in one [`AST`] into another, +For example, the `AST::merge` method allows merging all functions in one [`AST`] into another, forming a new, combined, group of functions. In general, there are two types of _namespaces_ where functions are looked up: @@ -136,7 +136,7 @@ the subsequent call using the _namespace-qualified_ function name fails to find function named '`message`' in the global namespace. Therefore, when writing functions for a [module] intended for the [`GlobalFileModuleResolver`][module resolver], -make sure that those functions are as _pure_ as possible and avoid cross-calling them from each other. +make sure that those functions are as independent as possible and avoid cross-calling them from each other. A [function pointer] is a valid technique to call another function in an environment-independent manner: diff --git a/doc/src/rust/modules/resolvers.md b/doc/src/rust/modules/resolvers.md index 92fa6074..451388af 100644 --- a/doc/src/rust/modules/resolvers.md +++ b/doc/src/rust/modules/resolvers.md @@ -16,12 +16,12 @@ which simply loads a script file based on the path (with `.rhai` extension attac Built-in module resolvers are grouped under the `rhai::module_resolvers` module namespace. -| Module Resolver | Description | Namespace | -| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------: | -| `FileModuleResolver` | The default module resolution service, not available under [`no_std`] or [WASM] builds. Loads a script file (based off the current directory) with `.rhai` extension.
The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.
`FileModuleResolver::create_module()` loads a script file and returns a module. | Module (cannot access global namespace) | -| `GlobalFileModuleResolver` | A simpler but more efficient version of `FileModuleResolver`, intended for short utility modules. Not available under [`no_std`] or [WASM] builds. Loads a script file (based off the current directory) with `.rhai` extension.
**Note:** All functions are assumed absolutely _pure_ and cannot cross-call each other.
The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.
`FileModuleResolver::create_module()` loads a script file and returns a module. | Global | -| `StaticModuleResolver` | Loads modules that are statically added. This can be used under [`no_std`]. | Global | -| `ModuleResolversCollection` | A collection of module resolvers. Modules will be resolved from each resolver in sequential order.
This is useful when multiple types of modules are needed simultaneously. | Global | +| Module Resolver | Description | Namespace | +| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------: | +| `FileModuleResolver` | The default module resolution service, not available under [`no_std`] or [WASM] builds. Loads a script file (based off the current directory) with `.rhai` extension.
The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.
`FileModuleResolver::create_module()` loads a script file and returns a module. | Module (cannot access global namespace) | +| `GlobalFileModuleResolver` | A simpler but more efficient version of `FileModuleResolver`, intended for short utility modules. Not available under [`no_std`] or [WASM] builds. Loads a script file (based off the current directory) with `.rhai` extension.
**Note:** All functions are assumed independent and cannot cross-call each other.
The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.
`FileModuleResolver::create_module()` loads a script file and returns a module. | Global | +| `StaticModuleResolver` | Loads modules that are statically added. This can be used under [`no_std`]. | Global | +| `ModuleResolversCollection` | A collection of module resolvers. Modules will be resolved from each resolver in sequential order.
This is useful when multiple types of modules are needed simultaneously. | Global | Set into `Engine` diff --git a/src/module.rs b/src/module.rs index 74c2b8da..532467d9 100644 --- a/src/module.rs +++ b/src/module.rs @@ -1400,7 +1400,7 @@ mod file { /// Module resolution service that loads module script files from the file system. /// - /// All functions in each module are treated as strictly _pure_ and cannot refer to + /// All functions in each module are treated as strictly independent and cannot refer to /// other functions within the same module. Functions are searched in the _global_ namespace. /// /// For simple utility libraries, this usually performs better than the full `FileModuleResolver`.