Change pure to independent.
This commit is contained in:
parent
6a53c446d3
commit
e637bfa51d
@ -10,7 +10,7 @@ Each Function is a Separate Compilation Unit
|
|||||||
This means that individual functions can be separated, exported, re-grouped, imported,
|
This means that individual functions can be separated, exported, re-grouped, imported,
|
||||||
and generally mix-'n-match-ed with other completely unrelated scripts.
|
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.
|
forming a new, combined, group of functions.
|
||||||
|
|
||||||
In general, there are two types of _namespaces_ where functions are looked up:
|
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.
|
function named '`message`' in the global namespace.
|
||||||
|
|
||||||
Therefore, when writing functions for a [module] intended for the [`GlobalFileModuleResolver`][module resolver],
|
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:
|
A [function pointer] is a valid technique to call another function in an environment-independent manner:
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ 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.
|
Built-in module resolvers are grouped under the `rhai::module_resolvers` module namespace.
|
||||||
|
|
||||||
| Module Resolver | Description | 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.<br/>The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.<br/>`FileModuleResolver::create_module()` loads a script file and returns a module. | Module (cannot access global 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.<br/>The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.<br/>`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.<br/>**Note:** All functions are assumed absolutely _pure_ and cannot cross-call each other.<br/>The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.<br/>`FileModuleResolver::create_module()` loads a script file and returns a module. | Global |
|
| `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.<br/>**Note:** All functions are assumed independent and cannot cross-call each other.<br/>The base directory can be changed via the `FileModuleResolver::new_with_path()` constructor function.<br/>`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 |
|
| `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.<br/>This is useful when multiple types of modules are needed simultaneously. | Global |
|
| `ModuleResolversCollection` | A collection of module resolvers. Modules will be resolved from each resolver in sequential order.<br/>This is useful when multiple types of modules are needed simultaneously. | Global |
|
||||||
|
|
||||||
|
@ -1400,7 +1400,7 @@ mod file {
|
|||||||
|
|
||||||
/// Module resolution service that loads module script files from the file system.
|
/// 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.
|
/// 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`.
|
/// For simple utility libraries, this usually performs better than the full `FileModuleResolver`.
|
||||||
|
Loading…
Reference in New Issue
Block a user