From: Peter Seibel
Subject: Restarts implemented with catch/throw?
Date: 
Message-ID: <m3d6h4h6an.fsf@javamonkey.com>
While looking back through old posts I found the following statement
in a 1999 post from Kent Pitman[1];

  "Restarts are implemented with catch/throw, after all."

I've been puzzling over what that means and haven't been able to wrap
my head around it.

My own mental model of how restarts work is that RESTART-BIND creates
a restart object and stores it in some dynamic variable which
COMPUTE-RESTARTS will later look in when trying to find available
restarts. (The restart object encapsulates the main function
associated with the restart as well as the interactive, report, and
test functions.) This dynamic variable will be some sort of data
structure that can hold a stack of associations between a
name/condition pairs and the restart objects.

RESTART-CASE, as the Notes section of its dictionary entry in the CLHS
explains, is then implemented on top of RESTART-BIND, by using
closed-over GO expressions to transfer control to the appropriate
restart code. Since this transfer via the closed-over GOs implicitly
unwinds the stack I don't have any place in my model where THROW and
CATCH would be used.

What am I missing or misunderstanding?

-Peter

[1] Message-ID: <···············@world.std.com>


-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: Kent M Pitman
Subject: Re: Restarts implemented with catch/throw?
Date: 
Message-ID: <sfw7k7cs9tj.fsf@shell01.TheWorld.com>
Peter Seibel <·····@javamonkey.com> writes:

> While looking back through old posts I found the following statement
> in a 1999 post from Kent Pitman[1];
> 
>   "Restarts are implemented with catch/throw, after all."
> 
> I've been puzzling over what that means and haven't been able to wrap
> my head around it. [...]
> 
> RESTART-CASE, as the Notes section of its dictionary entry in the CLHS
> explains, is then implemented on top of RESTART-BIND, by using
> closed-over GO expressions to transfer control to the appropriate
> restart code. Since this transfer via the closed-over GOs implicitly
> unwinds the stack I don't have any place in my model where THROW and
> CATCH would be used.
> 
> What am I missing or misunderstanding?

The possibility that I can't help you without a URL?  I don't know how 
to turn a message-id into a message.  Maybe you do...

Not having been able to see the specific post, and only working generally,
a couple of other possibilities are always:

 - The possibility of speaking figuratively.
 - The possibility that I was wrong.
 - The possibility that I was not serious.

Before fussing overly about things I say, it's best to just send me
email and ask if I was speaking rigorously and/or if I was in error, etc.

I doubt I was intending to dictate an implementation strategy that
must be used.

If you go to http://www.nhplace.com/kent/CL/ you can find an early 
implementation of restarts (it's not conforming to ANSI CL because we
later added some bells and whistles not reflected there, but the basic
manner of implementation would still work so it suffices for learning
purposes).

Btw, I'm nearly positive that catch/throw can be implemented with
block/return-from (and that I did this a few weeks ago in response to
someone asking).  Further, I'm nearly positive that block/return could
be implemented using go (with some possible fudging due to namespace
issues I've not thought through, but certainly the control parts are
easy to do).  Consequently, in order to know which of these was used
in any given implementation, you'd almost have to see the source or 
do some disassembling.  

The thing about restarts I was probably referring to is that they are
about creating a 'continuation' and then making it dynamically accessible
using a public repository of tags that are dynamically, not lexically,
established and disestablished.  That also describes what catch/throw
does... except that restarts come with more "introspective mechanism".

Does any of this help?
From: Peter Seibel
Subject: Re: Restarts implemented with catch/throw?
Date: 
Message-ID: <m365mwgw2p.fsf@javamonkey.com>
Kent M Pitman <······@world.std.com> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> > While looking back through old posts I found the following statement
> > in a 1999 post from Kent Pitman[1];
> > 
> >   "Restarts are implemented with catch/throw, after all."
> > 
> > I've been puzzling over what that means and haven't been able to wrap
> > my head around it. [...]
> > 
> > RESTART-CASE, as the Notes section of its dictionary entry in the CLHS
> > explains, is then implemented on top of RESTART-BIND, by using
> > closed-over GO expressions to transfer control to the appropriate
> > restart code. Since this transfer via the closed-over GOs implicitly
> > unwinds the stack I don't have any place in my model where THROW and
> > CATCH would be used.
> > 
> > What am I missing or misunderstanding?
> 
> The possibility that I can't help you without a URL?  I don't know how 
> to turn a message-id into a message.  Maybe you do...

I use Google, Advanced Groups Search. In this case the URL turns out to be:

 <http://www.google.com/groups?as_umsgid=sfwg13locdf.fsf%40world.std.com>

> Not having been able to see the specific post, and only working
> generally, a couple of other possibilities are always:
> 
>  - The possibility of speaking figuratively.
>  - The possibility that I was wrong.
>  - The possibility that I was not serious.
> 
> Before fussing overly about things I say, it's best to just send me
> email and ask if I was speaking rigorously and/or if I was in error,
> etc.
> 
> I doubt I was intending to dictate an implementation strategy that
> must be used.
> 
> If you go to http://www.nhplace.com/kent/CL/ you can find an early 
> implementation of restarts (it's not conforming to ANSI CL because we
> later added some bells and whistles not reflected there, but the basic
> manner of implementation would still work so it suffices for learning
> purposes).

Thanks. I had read the Condition System, Revision #18 but hadn't seen
the link to the sample implementation before. Having just glanced at
it, it looks like it works about how I imagined. I'll take a closer
look later.

> Btw, I'm nearly positive that catch/throw can be implemented with
> block/return-from (and that I did this a few weeks ago in response to
> someone asking).  Further, I'm nearly positive that block/return could
> be implemented using go (with some possible fudging due to namespace
> issues I've not thought through, but certainly the control parts are
> easy to do).  Consequently, in order to know which of these was used
> in any given implementation, you'd almost have to see the source or 
> do some disassembling.  

That makes sense. Now that you mention it, TAGBODY and GO (combined
with GENSYM and dynamic variables) do seem to provide all the
primitive facitilities you need for BLOCK/RETURN-FROM and CATCH/THROW
given that you can close over the tags to provide stack unwinding.
Interesting.

> The thing about restarts I was probably referring to is that they are
> about creating a 'continuation' and then making it dynamically accessible
> using a public repository of tags that are dynamically, not lexically,
> established and disestablished.  That also describes what catch/throw
> does... except that restarts come with more "introspective mechanism".

> Does any of this help?

Yup. Thanks.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Edi Weitz
Subject: Re: Restarts implemented with catch/throw?
Date: 
Message-ID: <8765mw9zm4.fsf@bird.agharta.de>
Kent M Pitman <······@world.std.com> writes:

> The possibility that I can't help you without a URL?  I don't know
> how to turn a message-id into a message.  Maybe you do...

To give an answer you yourself gave just three days ago:

  <http://www.google.com/advanced_group_search>

Or do it directly via

  <http://groups.google.com/groups?selm=MESSAGE-ID>

Cheers,
Edi.


  "You know, well-adjusted people in this technological age make do
   with the message-id."

  (Erik Naggum, c.l.l, 2003-01-13)