From: Donald H. Mitchell
Subject: finding multiple instances of the same restart
Date: 
Message-ID: <572j08$344@dropit.pgh.net>
We liberally use conditions, restarts, and handlers in our code to 
communicate between the "code" and the UI.  For example, (our system is a 
project management system), if cost leveling discerns that it's impossible 
to bring a task in under budget, it signals a condition to that effect.  We 
have numerous restarts sprinkled throughout the code to offer potential 
solutions to such problems (such as increasing the budget).  In some code, 
the user can put off some repairs until they go through all the potential 
causes.  I then have a condition and a restart that asks the user if they'd 
like to go back through the causes again (and the restart is for making it 
so).  The restart uses simple recursion.

OK, so, here's the problem of the day: when recursing, all the restarts in the 
recursion set will be available as many times as it has recursed and thus 
listed multiply to the poor baffled user.  My gut reaction is to add (not 
(find-restart 'whateverthisonescalled)) to the :test of the restart, but then 
I got nervous.  Why wouldn't that test find the very restart that it was in?  
Is find-restart guaranteed to only find those deeper in the stack (more local 
to the problem)?

This simplified example [very useless code] works in ACLwin, but I'm still 
nervous:

(in-package :cl-user) 

(define-condition garbage ()
  ())

(defun test ()
  (restart-case
      (restart-case
          (compute-restarts (make-condition 'garbage))
        (restart ()
          :test (lambda (cond)
                  (not (find-restart 'restart)))
          "Should be available"))
    (restart ()
      :test (lambda (cond)
              (not (find-restart 'restart)))
      "Shouldn't be available")))

(test)
(#<restart @ #x17A94B0>)


Donald H. Mitchell              ยทยทยท@pgh.net
Proactive Solutions, Inc.       412.835.2410
5858 Horseshoe Dr.              412.835.2411 (fax)
Bethel Park, PA 15102