From: Paul F. Dietz
Subject: RESTART-CASE question on associating conditions with restarts
Date: 
Message-ID: <LuadnW6SP9vYNeCjXTWcqg@dls.net>
According to the page for RESTART-CASE:

    If the restartable-form is a list whose car is any of
    the symbols signal, error, cerror, or warn (or is a macro
    form which macroexpands into such a list), then
    with-condition-restarts is used implicitly to associate
    the indicated restarts with the condition to be signaled.

So what should this return:

   (let ((c2 (make-condition 'error))
	(c1 (make-condition 'error)))
     (handler-bind
      ((error #'(lambda (c) (invoke-restart (find-restart 'foo c)))))
      (restart-case
       (restart-case
        (signal (progn (signal c2) c1))
        (foo () 'inner))
       (foo () 'outer))))

That is, is the inner restart not associated with any conditions at the
time the inner signal form is evaluated?

Some existing lisps (even commercial ones) differ on the meaning
of this form.

	Paul

From: Kent M Pitman
Subject: Re: RESTART-CASE question on associating conditions with restarts
Date: 
Message-ID: <sfwznnlbx97.fsf@shell01.TheWorld.com>
"Paul F. Dietz" <·····@dls.net> writes:

> According to the page for RESTART-CASE:
> 
>     If the restartable-form is a list whose car is any of
>     the symbols signal, error, cerror, or warn (or is a macro
>     form which macroexpands into such a list), then
>     with-condition-restarts is used implicitly to associate
>     the indicated restarts with the condition to be signaled.
> 
> So what should this return:
> 
>    (let ((c2 (make-condition 'error))
> 	(c1 (make-condition 'error)))
>      (handler-bind
>       ((error #'(lambda (c) (invoke-restart (find-restart 'foo c)))))
>       (restart-case
>        (restart-case
>         (signal (progn (signal c2) c1))
>         (foo () 'inner))
>        (foo () 'outer))))
> 
> That is, is the inner restart not associated with any conditions at the
> time the inner signal form is evaluated?

That might be so.  Though what that will mean, of course, is that it is 
available to all conditions, not that it is available to no conditions.
I can't tell if that's what you expect.
 
> Some existing lisps (even commercial ones) differ on the meaning
> of this form.

Just as the standard says, the inner restart-case will be
automatically associated with the SIGNAL.  The outer restart-case not
be automatically associated with the SIGNAL.  This wasn't, by the way,
a point of good theory so much as that there were limits of how much
work we wanted to tell implementations to do.

It's pretty apparent that (RESTART-CASE (ERROR ...) ...) is trying to set
up handlers for ERROR, but it's also apparent that
 (RESTART-CASE (FOO) ...)
is just setting up for arbitrary dynamic errors that can be anywhere
in the call to FOO.  The case you have where two RESTART-CASE's are nested
is one in which the outer one is going to behave like the dynamic kind
and the inner one like the static kind.  If you want them both to associate
restarts with the condition, you either have to do more work manually or
you need to seam them up so that all restarts are in one RESTART-CASE.

 1. c2 becomes bound to an ERROR condition.
 2. c1 becomes bound to an ERROR condition
 3. a handler is established that will invoke the FOO restart for a condition
 4. a RESTART-CASE for (outer) FOO is established dynamically for all
    conditions
 5. a RESTART-CASE for (inner) FOO begins to be established.
    probably the restart is in place but the association is not yet made.
 6. in order to compute the associations for restarts in [5],
    (progn (signal c2) c1) is executed.
 7. c2 is signaled.
 8. the handler for c2 finds a FOO restart for c, (inner) FOO
    because it is still a dynamic handler [has not yet been associated
    with a condition]
 9. INNER is returned from the inner RESTART-CASE
10. the outer RESTART-CASE returns the value from the inner

That's what I _think_ happens, anyway.  I think the spec leaves enough
latitude that during [5], if the restarts somehow don't get established
until after [6] is computed, then OUTER will get found by the
FIND-RESTART instead of INNER, and that value returned.  Just my opinion.

Does this help at all?
From: Paul F. Dietz
Subject: Re: RESTART-CASE question on associating conditions with restarts
Date: 
Message-ID: <dn2dnVibx6AmuuOjXTWcpQ@dls.net>
Kent M Pitman wrote:

> Does this help at all?

Very much so.  Thanks!

	Paul