I am confused by this error message.
; ; File: /root/erlisp/erlisp-cmucl/erlisp/src/manager.lisp
; In: DEFUN SYSTEM-MANAGER-PROCESS
; (RECEIVE-WITH-MATCHER (COND-MATCHER M) (T M)) ; Error: (during macroexpansion) ; Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER: the function LISTEN-TO-SYSTEM-MANAGER is undefined. ; ; Error: (during macroexpansion) ; Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER: the function LISTEN-TO-SYSTEM-MANAGER is undefined. ; ; Converted SYSTEM-MANAGER-PROCESS.
It complains that function LISTEN-TO-SYSTEM-MANAGER is undefined, but you can see here that this undefined function is defined immediately before the function that complains about it being missing. It seems like everything I've tried over the last two days lead to some sort of missing function error, and this still doesn't make sense to me. When I write small Lisp codes on my own, it doesn't seem to matter in which order I define functions. As long as all the functions are defined before I start actually running the functions, everything just works. What is different here? Is symbol scope related to
Excerpt from manager.lisp:
(defun listen-to-system-manager () (when (slot-value (current-process) 'time-to-die) (suicide "System manager requested termination.")))
(defun system-manager-process () (do ((msg (receive-with-matcher (cond-matcher m) (t m)) (receive-with-matcher (cond-matcher m) (t m)))) (nil) (cond ((eq 'link (first msg)) (setf (gethash (list (second msg) (third msg)) *link-table*) (fourth msg))) ((eq 'exit (first msg)) (maphash #'(lambda (k v) (let ((src (second msg)) (reason (third msg))) (when (member src k) (when (eq src (first k)) (cond ((or (eq v 'notify) (and (eq v 'default) (eq reason 'normal))) (send (second k) msg)) (t (kill-process (second k))))) (remhash k *link-table*)))) *link-table*)))))
For reference, I have enclosed manager.lisp (new) and process.lisp (modified).
Eric
On 9/2/05, Eric Lavigne lavigne.eric@gmail.com wrote:
I am confused by this error message.
; ; File: /root/erlisp/erlisp-cmucl/erlisp/src/manager.lisp
; In: DEFUN SYSTEM-MANAGER-PROCESS
; (RECEIVE-WITH-MATCHER (COND-MATCHER M) (T M)) ; Error: (during macroexpansion) ; Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER: the function LISTEN-TO-SYSTEM-MANAGER is undefined.
In the files you attached there was no call to this function, and as I have not checked out the source I can't be sure, but apparently some macro calls LISTEN-TO-SYSTEM-MANAGER during its expansion.
Now normally macroexpansion happens before functions are loaded. Therefore a macro should normally expand without calling functions (but may of course include function calls in the generated expansion code).
When you really want to have a function to be available at macro-expansion time, you have to wrap the function in eval-when, like what now happens already with many functions in messaging.lisp:
(eval-when (:compile-toplevel :load-toplevel :execute) (defun LISTEN-... (..) ..) )
- Willem
I am confused by this error message.
; ; File: /root/erlisp/erlisp-cmucl/erlisp/src/manager.lisp
; In: DEFUN SYSTEM-MANAGER-PROCESS
; (RECEIVE-WITH-MATCHER (COND-MATCHER M) (T M)) ; Error: (during macroexpansion) ; Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER: the function LISTEN-TO-SYSTEM-MANAGER is undefined.
In the files you attached there was no call to this function, and as I have not checked out the source I can't be sure, but apparently some macro calls LISTEN-TO-SYSTEM-MANAGER during its expansion.
Probably these calls occur in messaging.lisp. I forgot to include that file, and I won't have access to that computer again until tonight. Each process uses that function before send/receive to check whether it has orders to die.
Now normally macroexpansion happens before functions are loaded. Therefore a macro should normally expand without calling functions (but may of course include function calls in the generated expansion code).
receive-with-matcher is a macro. listen-to-system-manager is called at the beginning of that macro. Instead, the macro should just be producing code that calls listen-... instead of calling listen-... and then producing code. I see my mistake now.
When you really want to have a function to be available at macro-expansion time, you have to wrap the function in eval-when, like what now happens already with many functions in messaging.lisp:
(eval-when (:compile-toplevel :load-toplevel :execute) (defun LISTEN-... (..) ..) )
I don't need it at macro-expansion time. I was treating macros as though they were functions. This should be easy to fix now that I know what the problem is. Without seeing the function call, how did you figure out that I was calling that "missing function" from a macro?
Eric