Handle to loaded modules.
Class Module
The module class is a handle by which the scripts can read or write other modules symbols. It should not be instantiated directly by scripts; module class instances are returned by the Compiler methods.
Methods | |
attributes | Gets the decoration attributes of this module. |
engineVersion | Returns the version numbers of the compilation engine. |
exported | Returns the list of exported symbols available in this module. |
get | Retreives a value from the target module. |
getReference | Retreives a value from the target module. |
globals | Returns the list of global symbols available in this module. |
moduleVersion | Returns the version numbers of the module. |
set | Changes a value in the target module. |
unload | Removes the module from the running virtual machine. |
Gets the decoration attributes of this module.
Module.attributes()
Return | A dictionary with the attributes or nil if the module provides none. |
Returns the version numbers of the compilation engine.
Module.engineVersion()
Return | A three element array containing version, subversion and patch number. |
Returns an array of three numeric elements, indicating the version number of the engine under which the given module was compiled. The value is available both for binary modules and for pre-compiled Falcon modules. Modules compiled on the fly will report the same version number of the running Virtual Machine.
Returns the list of exported symbols available in this module.
Module.exported()
Return | An array containing all the exported symbols. |
This method returns an array containing a list of strings, each one representing a name of a global symbol exported by this module.
The symbol names can be then fed in Module.set and Module.get methods to manipulate the symbols in the module.
Notice that exported symbols are ignored by the module loader; they are used by the Virtual Machine to fulfil load requests, but this doesn't imply that they are honoured in every case.
Retreives a value from the target module.
Module.get( symName )
symName | The name of the symbol to be loaded. | ||
Raise |
|
If the module provides a global symbol with the given name, the value of the symbol is returned. Nil may be a valid return value; in case the symbol is not found, an AccessError is raised.
Retreives a value from the target module.
Module.getReference( symName )
symName | The name of the symbol to be referenced. | ||
Return | A reference to the desired item. | ||
Raise |
|
Loads a reference to the given symbol in the target module. On success, after this call assignments to the returned variable will be immediately reflected in both the modules, be them applied in the caller or in the loaded module. To break the reference, use the $0 operator as usual.
In case the symbol is not found, an AccessError is raised.
Returns the list of global symbols available in this module.
Module.globals()
Return | An array containing all the global symbols. |
This method returns an array containing a list of strings, each one representing a name of a global symbol exposed by this module.
The symbol names can be then fed in Module.set and Module.get methods to manipulate the symbols in the module.
Returns the version numbers of the module.
Module.moduleVersion()
Return | A three element array containing version, subversion and patch number. |
Returns the module version information in a three element array. The numbers represent the development status of the module as its developers advertise it.
Version informations for scripts compiled on the fly and for .fam modules are provided through the "version" directive.
Changes a value in the target module.
Module.set( symName, value )
symName | The name of the symbol to be changed. | ||
value | The new value to be set. | ||
Raise |
|
Sets the value of a global symbol in the target module. The value may be any kind of Falcon item, including a reference, in which case any change to the local value is immediately reflected in the target module.
In case the symbol is not found, an AccessError is raised.
Removes the module from the running virtual machine.
Module.unload()
Return | True on success, false on failure. |
Unloads the module, eventually destroying it when there aren't other VMs referencing the module.
To actually unload the module, it is necessary not to hold any reference to items served by the given module (functions, classes, objects and so on). Strings are copied locally, so they can still exist when the module is unloaded.