[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem in initialize-instance
- To: Gregor.pa@Xerox.COM, poman@CS.UCLA.EDU
- Subject: Re: problem in initialize-instance
- From: Warren Harris <harris%hplwhh@hplabs.HP.COM>
- Date: Wed, 17 Aug 88 12:48:18 PDT
- Cc: commonloops.PA@Xerox.COM
- In-reply-to: Your message of Tue, 16 Aug 88 10:33:00 -0700. <19880816173326.0.GREGOR@PORTNOY.parc.xerox.com>
- Redistributed: commonloops.PA
Here's a patch we did for HP Common Lisp which also has a non-reentrant
compiler. It has the nasty feature of redefining the function COMPILE, but
what it does is returns a closure that will compile the function later
(when the function is invoked at runtime and the compiler is not running)
if the compiler is currently active. You'll need to find a way in KCL to
figure out if the compiler is running. The flag COMPILER::*COMP-RUNNING*
does this in HP-CL.
Warren
(in-package :lisp)
(unless (fboundp 'basic-compile)
(setf (symbol-function 'basic-compile)
(symbol-function 'compile)))
(defun deferred-compile (name &optional definition)
(if compiler::*comp-running* ; is the compiler running?
;; then return a function which not only executes the definitions, but
;; also compiles itself at runtime (later when the compiler is not running)
(let* ((original-definition (or definition
(symbol-function name)))
(deferred-function #'(lambda (&rest args)
(if compiler::*comp-running*
(apply original-definition args)
(apply (if (null definition)
(basic-compile name)
(basic-compile name definition))
args)))))
(if name
(progn
(setf (symbol-function name) deferred-function)
name)
deferred-function))
;; else, the compiler is not running, so call the old compile function
(if (null definition)
(basic-compile name)
(basic-compile name definition))))
(eval-when (eval load)
(setf (symbol-function 'compile)
(symbol-function 'deferred-compile)))