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

Top level forms in a compiled file



    The evaluation order here is absolutely critical, and kills your whole thing.
    It is completely reasonable and extraordinarily common to call functions 
    defined two lines above.  I guess you could say, "Well, run it at the end,
    not at the beginning", but there could be load-time forms in your functions.

This is handled in PSL by having function definitions add a call to FSET
to the list of top level forms to be compiled.  It is exactly as if
DEFUN were just defined as a macro and didn't cause any special behavior
on the part of the compiler!  Just wrap (lambda () ...) around
everything in the file, and compile it.  (Not actually true, but the
behavior is the same.) E.g.

(defmacro defun (name &body body)
  `(setf (symbol-function ',name)
	#',(lambda ,@body)))

Even defining a function twice in a single file and using both
definitions works.