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

Re: catch-cancel



At 10:56 AM 5/30/95, Michael Korcuska wrote:
>In article <korcuska-2805950935540001@korcuska.ils.nwu.edu>,
>korcuska@ils.nwu.edu (Michael Korcuska) wrote:
>
>> We ran into a strange problem the other day with catch-cancel and
>> throw-cancel.  Inside a catch-cancel we create a window with a button
>> which, when clicked, calls throw-cancel.  Unfortunately the throw wasn't
>> being caught by the catch we set up.
>>
>> After puzzling over this for a bit, we ditched (catch-cancel...) and used
>> (catch :my-cancel ...).  Now it works fine.
>>
>> Ok.  So catch-cancel must be doing something strange, right?
>
>Just following up to my own message.  Here's some code that illustrates
>the problem.  Just change *tag* to something other than :cancel and the
>code works.  Any comments?
>
>(defparameter *tag* :cancel)
>
>(let* ((btn (make-instance 'button-dialog-item
>              :view-size #@(60 20)
>              :view-position #@(20 40)
>              :dialog-item-text "Cancel"
>              :dialog-item-action #'(lambda (item)
>                                      (declare (ignore item))
>                                      (throw *tag* "Cancelled")))
>            )
>       (wind (make-instance 'window
>               :window-type :single-edge-box
>               :view-position :centered
>               :view-size #@(100 100)
>               :window-show nil
>               :view-subviews (list btn))))
>  (princ
>   (catch *tag*
>     (window-show wind)
>     (princ "Looping until cancel button clicked")
>     (loop for i from 1 to 500
>           do (princ ".")
>           finally (return "finished"))))
>  (window-close wind)
>  )


This happens because there is a (catch :cancel ....) in the event processor.
I don't have a good explanation for why its there.

Alice@digitool.com