AutoLoad — allows for run-time symbol lookup.


AutoLoad ("pattern", `action)




A shell style pattern.


An action to be taken when the pattern is matched.


The _auto_load_alist_, which is a list of all currently stored AutoLoad rules. Each rule is itself formatted as a list. This is the _auto_load_alist_ syntax:

((pattern action_func action_arg ...) ...)

The members of each rule list are as follows:


The AutoLoad pattern parameter.


The function specified in the AutoLoad action parameter.


The function argument(s) specified in the AutoLoad action parameter.

For example, the AutoLoad rules in AutoLoadLib.g (at the time of this writing) would be returned as follows:

(("P[Tthg]*" DllLoad "") ("gl[A-Z]*" DllLoad "")
 ("GLUT_*" DllLoad "") ("GLU_*" DllLoad "")
 ("GL_*" DllLoad "") ("ASCII_*" DllLoad "")
 ("KB_*" DllLoad "") ("GM_*" DllLoad "")
 ("EVT_*" DllLoad "") ("[mM][gG][lL]*" DllLoad "")
 ("[gG]tk*" DllLoad ""))


This function gives Gamma a way to look up symbols during run-time. If Gamma comes across an undefined symbol while executing a program, and if the symbol matches the pattern, then Gamma executes the action. Normally the action is either a direct definition of the symbol, or an attempt to load a DLL that defines the symbol, using DllLoad, for example.

The available patterns are as follows:

    *matches any number of characters, including zero.

    [c]matches a single character which is a member of the set contained within the square brackets.

    [^c]matches any single character which is not a member of the set contained within the square brackets.

    ?matches a single character.

    {xx,yy}matches either of the simple strings contained within the braces.

    \c(a backslash followed by a character) - matches that character.


This function is not part of the base Gamma executable. It is provided by a Gamma library AutoLoadLib.g which can be accessed using the Gamma require function like this:

require ("/usr/cogent/require/AutoLoadLib.g");



    In this example, we use the ClearAutoLoad function to clear the AutoLoad list just to make the steps easier to follow.

    Once a library is loaded or a symbol is defined, Gamma no longer sends a "Looking for symbol" message.

    Notice how although NoAutoLoad and ClearAutoLoad remove a pattern from future consideration, any symbols defined or any libraries loaded before they were called remain valid.

Gamma> require ("/usr/cogent/require/AutoLoadLib.g");
Gamma> ClearAutoLoad();
Gamma> AutoLoad ("[gG]tk*", `DllLoad (""));
(("[gG]tk*" DllLoad ""))
Gamma> gtk_arg_new;
Looking for gtk_arg_new
(defun gtk_arg_new (arg_type) ...)
Gamma> gtk_main;
(defun gtk_main () ...)
Gamma> testvar;
Looking for testvar
Symbol is undefined: testvar
debug 1> (Ctrl - D)
Gamma> AutoLoad("testvar", `testvar = 5);
(("testvar" setq testvar 5) ("[gG]tk*" DllLoad ""))
Gamma> testvar;
Looking for testvar
Gamma> NoAutoLoad("testvar");
(("[gG]tk*" DllLoad ""))
Gamma> testvar;
Gamma> ClearAutoLoad();
Gamma> gtk_main;
(defun gtk_main () ...)
Gamma> gtk_false;
(defun gtk_false () ...)

See Also

ClearAutoLoad, NoAutoLoad, DllLoad