[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

intercepting undefined function errors



   Date: Wed, 5 Aug 87 12:34 EDT
   From: Jeffrey P. Golden <jpg@allegheny.scrc.symbolics.com>

   As you may know, MACSYMA has long had an "autoload" feature 
   whereby an "undefined function" may have an AUTOLOAD property 
   which indicates a file which contains the function's definition. 
   The file is loaded when a call to the undefined function is 
   attempted.  (This scheme was very useful in the days of limited 
   address space.  It is still used to autoload a few "share" files.)

   To make it work under Lucid, we need a way to intercept 
   undefined function errors.  (It would be interesting if Lucid had 
   an autoload capability as did Maclisp, but I'm not expecting that.)
   We are willing to intercept all errors if need be as long as we can 
   detect which error we've got, handle those we can, and decline to 
   handle the others. 

   I cannot find the capability I need in the Lucid documentation. 
   Can someone tell me if there is a way to do what I want in Lucid?


The error is "signalled" by symbol-function.  Try redefining symbol-function in
the following manner:

  (defvar *system-symbol-function* #'symbol-function)

  (defun symbol-function (symbol)
    (when (not (fboundp symbol))
      ;; Do autoloading here.
      ...)
    (funcall *system-symbol-function* symbol))

If Lucid provided a reasonable way to give advice (as in Symbolics advise) you
would use that instead of this rather ugly redefinition.


Mark Bromley