Lisp HUG Maillist Archive

Interrupting a computation in capi

I have a loop which is doing computation, which on occasion may never
terminate, so I want to allow the user to interrupt it. At present I have
the following:

(defparameter *stop-computation* nil)

and a stop-button in the interface which starts the computation, which has
as its selection-callback:

(lambda () (setf *stop-computation* t))

The computation is started by a start-button in the same interface, and the
function which starts has the form:

(catch 'stop-computation
    (do-computation))

(defun do-computation ()
   (setf *stop-computation* nil)
    (loop
         for i from 0
         do (do-stuff)
         if *stop-computation* (throw 'stop-computation nil)
         do (more-stuff)))

However if, while the computation is executing, I click on the stop-button,
there is no effect. I suspect I am doing something dumb, but I can't figure
out what. Can anyone help?

Thanks

Jim Bushnell





________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________

Updated at: 2020-12-10 08:59 UTC