[previous] [up] [next]     [contents] [index]
Next: Parenthesis Matching Up: Application Toolbox Previous: Autosaving

Autoloading

MrEd's autoloading system can be used to delay loading Scheme code into MrEd until it is needed. Autoloading provides a mechanism for adding extensions to MrEd without paying the start-up and memory costs when the extension is unused.

The actual loading of an autoloaded file is triggered by the application of an autoloading procedure. An autoloading procedure is created with make-autoload:

  (make-autoload global-name file-name) 

The global-name parameter must be a symbol. The file-name procedure is the name of the autoloaded file that defines global-name as a procedure. The reuslt of make-autoload is a procedure that will pass its arguments on to the value of the global variable named global-name once it is defined.

If file-name does not include a directory path, the directories specified by the list mred:autoload-paths are searched for the file.

If global-name is undefined when the autoloading procedure is invoked, then the specified file is autoloaded (with load/cd). When global-name is defined (either by autoloading or by a previous loading of the file), then the function defined by global-name is invoked.

For example, suppose that a C++ mode handler called c++-mode-handler is defined in the file ``cppmode.ss''. This handler can be autoload-installed into the mode-handler table with:

  (mred:insert-mode-handler "C++" '("cc" "C")
        (make-autoload 'c++-mode-handler "cppmode.ss")) 


PLT