AL procedures

In ANSIG there is a compiler and run-time system for a special programming language called AL. The AL language has a number of predefined data types and a large number of pre-defined procedures (called intrinsics) which allow access to the facilities and database in ANSIG in a general and safe fashion.

The AL language allows the user to write implement entirely new procedures in ANSIG, in a way which is much more powerful than is possible with ordinary macros. There is a library of AL procedures in the distribution in the ansig/lib subdirectory.


Compilation

Files containing AL procedures are compiled with the commands COMPILE or RECOMPILE. The compiler checks for syntax and type errors. If an error is detected, then the offending line with its sequential number in the file is output, with an approximate position of the error. No AL procedures from the file are kept if an error occurs in it.

All AL procedures currently compiled into ANSIG can be removed by the INITIALIZE command.


Data types

Not yet written.

Invokation

An AL procedure is invoked from the command line by giving the AL procedure name followed by the arguments within parenthesis. The parenthesis are required even if the AL procedure has no arguments. In fact, the parenthesis are the signal that tells the command interpreter in ANSIG to look up the AL procedure and execute it, given the arguments (if any) within the parenthesis.

The invokation is performed as part of the usual command line processing, after variable and query substition.

There is no difference in the invokation of intrinsic or compiled procedures.

If the AL procedure returns a result, then it will be put into the command line instead of the invokation, before the command line is executed. It is therefore possible to give commands which do different things according to what value is returned by an AL procedure invokation in it.

For example, some simple calculations can be done like this:


ANSIG> echo Add (1.0, 3.0)
4.000000E+00

ANSIG> echo Exp (2.0)
7.389056E+00

ANSIG> echo Add (Exp (1.0), Sin (45.0))
3.569185E+00
It is possible to invoke AL procedures from the command line in a nested fashion; the innermost are executed first, so that their results can be used as arguments for the outermost AL procedure.

AL procedures which return lists, give the list name as result. The list name consists of a capital L and a number, which is guaranteed to be unique. It is often useful to rename the list in the same command as the Al procedure invokation. Use the RENAME command:

ANSIG> RENAME Spectra() all_spectra
This will create and store a list called all_spectra containing all spectra.

Overloading

Intrinsic AL procedures may be overloaded. This means that there may exists several different procedures with the same name (identifier), but with different types or numbers of arguments. The AL compiler can find the correct intrinsic procedure based on the given arguments.

It is not possible to overload user-written (compiled) AL procedures.


Intrinsics

A large set of AL procedures built into ANSIG, intrinsics, are available. The intrinsics are the means to access the functionality and database of ANSIG from AL procedures. Note that there are no operators in the AL language, i.e. no '=', '+', or such. All such functionality is instead implemented in the various intrinsic AL procedures.

The intrinsics are grouped into the following broad headings:


Per Kraulis 10 Apr 1996.