Question about compiled forms...
At this point I think I need to hear from some Lisp experts...I defined a macro to provide for early binding of functions in forms at compile time:
(defmacro defun-eb (name args &body body)
(let ((gform (gensym)))
`(progn
(defun ,name ,args ,@body)
(define-compiler-macro ,name (&whole ,gform ,@args)
`(funcall ,(symbol-function (first ,gform)) ,@(rest ,gform))))
))
Use it like this:
(defun foo () (list 10)
(defun bar () (1+ (car (foo))))
then redefine foo to provide an int instead of a list;
(defun foo () 10)
and bar keeps on ticking just like before, until you redefine it as
(defun bar () (1+ (foo))
So far this works great!!
Only problem here is that you can't compile these forms to a file. Lisp complains that these substituted closures in the compiled forms are non-externalizable functions. I have run into this before, and I know that the answer requires pushing these closures in after load time.
But how does a FASL file do it? It must be loading "non-externalizable functions", compiled to native code, nonetheless...
Any expert opinions on how to get around this issue? and how FASL files manage to pull it off?
If we could do this early-binding then we'd have a hybrid in Lisp that mimics some aspects of ML with its immutable bindings. That would be just great for deployed embedded code, where the full generality of Lisp is both costly and unwarranted. Eh?
Dr. David McClain
Chief Technical Officer
Refined Audiometrics Laboratory
4391 N. Camino Ferreo
Tucson, AZ 85750
email: dbm@refined-audiometrics.com
phone: 1.520.390.3995