use. Linking modules


use allows using a module from specified file. If path begins with symbol "/", it will be regarded as path from Web-space root. In any other case, Parser will look for the module by relative path first and then if nothing was found in directories specified in variable $CLASS_PATH in Configuration method.

Note: before version 3.4.1 Parser did not look for the module by relative path from the file with the processed
@USE/^use[] instruction.
Note: starting from version 3.4.3 the exception occurs in case of loading class if a class with the same name was already loaded. It can be switched off by specifying a new
$.replace(true) option.

The following construction can be used to link modules, too:
filename 1
filename 2

The difference between these constructions lies in that
@USE loads a module before a code is executed, while operator use can be called right from the script's body.
For example:


@USE since version 3.4.5 calls the
^use[] operator, which, like any other operator, can be overridden. This allows implementation of custom logic for loading modules. Use link to see the ^use[] operator implementation in Parser.

Note: attempts to use a module which were already used would not cause re-read of that module.

We do recommend that you save the results of code's work by linking necessary modules with operator
use within the code of operator cache.

Copyright © 1997–2017 Art. Lebedev Studio | Last updated: 26.04.2017