Load a function from a file
autoload (String_Type funct, String_Type file)
The autoload
function is used to declare funct
to the
interpreter and indicate that it should be loaded from file
when
it is actually used.
Suppose bessel_j0
is a function defined in the file
bessel.sl
. Then the statement
autoload ("bessel_j0", "bessel.sl");
will cause bessel.sl
to be loaded prior to the execution of
bessel_j0
evalfile
Compile a file to byte-code for faster loading.
byte_compile_file (String_Type file, Integer_Type method)
The byte_compile_file
function byte-compiles file
producing a new file with the same name except a 'c'
is added
to the output file name. For example, file
is
"site.sl"
, then the function produces a new file named
site.slc
.
The method
parameter is not used in the current
implementation. Its use is reserved for the future. For now, set
it to 0
.
evalfile
Interpret a string as S-lang code
eval (String_Type expression)
The eval
function parses a string as S-Lang code and executes the
result. This is a useful function in many contexts such as dynamically
generating function definitions where there is no way to generate
them otherwise.
if (0 == is_defined ("my_function"))
eval ("define my_function () { message (\"my_function\"); }");
is_defined, autoload, evalfile
Interpret a file containing S-lang code.
Integer_Type evalfile (String_Type file)
The evalfile
function loads file
into the interpreter.
If no errors were encountered, 1
will be returned; otherwise,
a S-lang error will be generated and the function will return zero.
define load_file (file)
{
ERROR_BLOCK { _clear_error (); }
() = evalfile (file);
}
eval, autoload