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

Nasty interaction of toplevel and menu-items



Hi to all...

I've been working on a small program that replaces the toplevel loop with one
of my 
own.  However, I'm doing something wrong (aargh)!  When I take over the loop, 
anything typed into the Listener gets listened to correctly, but any function
called from a 
menu-item that contains a (format t ) breaks in an odd way.  Basically, it
looks like the 
output of the format calls are being evaluated.  So, if my menu calls a
function (test), and 
test contains a call (format t "This will break"), my toplevel responds 
> Error: Unbound variable: THIS
> While executing: SYMBOL-VALUE
> Type Command-/ to continue, Command-. to abort.
> If continued: Retry getting the value of THIS.
See the RestartsU menu item for further choices.
as if I had typed "This".  

Code to produce this error is below:
;;;; Toplevel code to show break

;; set-top is an accessor function to set the toplevel routine
;; new-top is the new toplevel routine

(defun set-top (top-level-fn)
   (%set-toplevel top-level-fn)
   (throw :toplevel t))

(defun new-top (&aux form)
   (format t "~&LISP> ")
   (setq form (read))
   (format t "~& ~a" (eval form)))

;; now just create the test case

(defun test ()
   (format t "This will break"))

(defparameter *stupid-menu* (make-instance 'menu
                                                    :menu-title "Test"
                                                    :menu-items
                                                    (list
                                                      (make-instance 'menu-item
                                                          :menu-item-title
"Breaks"
                                                          :menu-item-action 
                                                          #'(lambda ()
(test))))))

(menu-install *stupid-menu*)


I don't have any good ideas about what's going on -- maybe I'm confused about
the 
various streams?  Advice would be gratefully appreciated.


Thanks,

Douglas Merrill
Visiting Scholar
The Institute for the Learning Sciences
Northwestern University
1890 Maple Ave
Evanston IL 60201
dmerrill@ils.nwu.edu