2.2.3Class Module

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
attributesGets the decoration attributes of this module.
engineVersionReturns the version numbers of the compilation engine.
exportedReturns the list of exported symbols available in this module.
getRetreives a value from the target module.
getReferenceRetreives a value from the target module.
globalsReturns the list of global symbols available in this module.
moduleVersionReturns the version numbers of the module.
setChanges a value in the target module.
unloadRemoves the module from the running virtual machine.

Methods

attributes

Gets the decoration attributes of this module.

Module.attributes()
ReturnA dictionary with the attributes or nil if the module provides none.

engineVersion

Returns the version numbers of the compilation engine.

Module.engineVersion()
ReturnA 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.

exported

Returns the list of exported symbols available in this module.

Module.exported()
ReturnAn 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.

get

Retreives a value from the target module.

Module.get( symName )
symName The name of the symbol to be loaded.
Raise
AccessError if the symbol name is not found.

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.

getReference

Retreives a value from the target module.

Module.getReference( symName )
symName The name of the symbol to be referenced.
ReturnA reference to the desired item.
Raise
AccessError if the symbol name is not found.

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.

globals

Returns the list of global symbols available in this module.

Module.globals()
ReturnAn 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.

moduleVersion

Returns the version numbers of the module.

Module.moduleVersion()
ReturnA 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.

set

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
AccessError if the symbol name is not found.

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.

unload

Removes the module from the running virtual machine.

Module.unload()
ReturnTrue 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.

Made with http://www.falconpl.org