Next Previous Contents

15. Eval Functions

15.1 autoload

Synopsis

Load a function from a file

Usage

autoload (String_Type funct, String_Type file)

Description

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.

Example

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
See Also

evalfile

15.2 byte_compile_file

Synopsis

Compile a file to byte-code for faster loading.

Usage

byte_compile_file (String_Type file, Integer_Type method)

Description

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.

Notes

The method parameter is not used in the current implementation. Its use is reserved for the future. For now, set it to 0.

See Also

evalfile

15.3 eval

Synopsis

Interpret a string as S-lang code

Usage

eval (String_Type expression)

Description

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.

Example

    if (0 == is_defined ("my_function"))
      eval ("define my_function () { message (\"my_function\"); }");
See Also

is_defined, autoload, evalfile

15.4 evalfile

Synopsis

Interpret a file containing S-lang code.

Usage

Integer_Type evalfile (String_Type file)

Description

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.

Example

    define load_file (file)
    {
       ERROR_BLOCK { _clear_error (); }
       () = evalfile (file);
    }
See Also

eval, autoload


Next Previous Contents