From: Douglas Philips
Subject: UNWIND-PROTECT clarification....
Date: 
Message-ID: <403a0bd5$1_3@news.nauticom.net>
Have stared into the HyperSpec too long, it stares back at me, but 
enlightened I am not, nor has a google groups search found the 
information I seek, though perhaps I was unable to articulate the 
correct search criteria...

In code shall I phrase my question, though the question may itself turn 
out to be "incorrect".

Are the semantics of this code defined by the ANSI Common Lisp standard, 
or would I be relying on a "forgiving" (heh) implementation:

(TAGBODY
           try-again
	  (UNWIND-PROTECT
		(my-fun-that-might-try-to-throw-or-signal-or-...)
		(GO try-again)))


To be used in a context, perhaps as a macro:
    (DEFMACRO repeat-with-no-escape (fun)
       (LET ((TAG (GENSYM)))
            `(TAGBODY ,TAG (UNWIND-PROTECT (FUNCALL ,fun) (GO , TAG)))))

Thanks,
     <D\'gou

From: Paul F. Dietz
Subject: Re: UNWIND-PROTECT clarification....
Date: 
Message-ID: <S_CdnWpMnoNEl6fdRVn-tw@dls.net>
Douglas Philips wrote:

> Are the semantics of this code defined by the ANSI Common Lisp standard, 
> or would I be relying on a "forgiving" (heh) implementation:
> 
> (TAGBODY
>           try-again
>       (UNWIND-PROTECT
>         (my-fun-that-might-try-to-throw-or-signal-or-...)
>         (GO try-again)))

The second, AFAICT.  The exit point for the go has its
extent terminated as soon as (my-fun-...) transfers to
something outside the tagbody.

	Paul
From: Kenny Tilton
Subject: Re: UNWIND-PROTECT clarification....
Date: 
Message-ID: <z3o_b.162339$cM1.31165200@twister.nyc.rr.com>
Douglas Philips wrote:
> Have stared into the HyperSpec too long, it stares back at me, but 
> enlightened I am not, nor has a google groups search found the 
> information I seek, though perhaps I was unable to articulate the 
> correct search criteria...
> 
> In code shall I phrase my question, though the question may itself turn 
> out to be "incorrect".
> 
> Are the semantics of this code defined by the ANSI Common Lisp standard, 
> or would I be relying on a "forgiving" (heh) implementation:
> 
> (TAGBODY
>           try-again
>       (UNWIND-PROTECT
>         (my-fun-that-might-try-to-throw-or-signal-or-...)
>         (GO try-again)))

Unrelated to your query, are you aware that the protected clauses of 
UNWIND-PROTECT execute even if my-fun-etc completes normally? You need 
something like:

(TAGBODY
      try-again
    (let (ok)
      (UNWIND-PROTECT
	(progn
             (my-fun-etc)
             (setf ok t))
        (unless ok
           (go try-again)))))


kt

-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application
From: Rahul Jain
Subject: Re: UNWIND-PROTECT clarification....
Date: 
Message-ID: <87brnpdx8h.fsf@nyct.net>
Douglas Philips <····@mac.com> writes:

> (TAGBODY
>            try-again
> 	  (UNWIND-PROTECT
> 		(my-fun-that-might-try-to-throw-or-signal-or-...)
> 		(GO try-again)))

I think what you're looking for is the condition system, having a
restart (go try-again) and then invoking that restart either from an
automatic handler or an interactive one. Think about what you'd do when
you REALLY want to exit the retry loop. With the automatic handler, you
could only have it apply to conditions that were of the types you'd
expect: timeouts, connections being denied, etc.

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: Barry Margolin
Subject: Re: UNWIND-PROTECT clarification....
Date: 
Message-ID: <barmar-739AD4.01530824022004@comcast.ash.giganews.com>
In article <··············@nyct.net>, Rahul Jain <·····@nyct.net> 
wrote:

> Douglas Philips <····@mac.com> writes:
> 
> > (TAGBODY
> >            try-again
> > 	  (UNWIND-PROTECT
> > 		(my-fun-that-might-try-to-throw-or-signal-or-...)
> > 		(GO try-again)))
> 
> I think what you're looking for is the condition system, having a
> restart (go try-again) and then invoking that restart either from an
> automatic handler or an interactive one. Think about what you'd do when
> you REALLY want to exit the retry loop. With the automatic handler, you
> could only have it apply to conditions that were of the types you'd
> expect: timeouts, connections being denied, etc.

The condition system only applies if the function tries to exit by 
signalling an error.  But from the name 
MY-FUN-THAT-MIGHT-TRY-TO-THROW-OR-SIGNAL-OR-..., it sure looks like he 
wants to trap attempted exits using THROW, RETURN-FROM, GO, etc.  These 
will all happily bypass a condition handler, and only UNWIND-PROTECT can 
catch them.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Douglas Philips
Subject: Re: UNWIND-PROTECT clarification....
Date: 
Message-ID: <403b56d4$1_2@news.nauticom.net>
Barry Margolin indited:

> The condition system only applies if the function tries to exit by 
> signalling an error.  But from the name 
> MY-FUN-THAT-MIGHT-TRY-TO-THROW-OR-SIGNAL-OR-..., it sure looks like he 
> wants to trap attempted exits using THROW, RETURN-FROM, GO, etc.  These 
> will all happily bypass a condition handler, and only UNWIND-PROTECT can 
> catch them.

Correct. There doesn't seem to be a way for the code in UNWIND-PROTECT's 
"recovery" section to figure out whether a non-local control-flow change 
is valid (the GO in my example is obviously suspect since there is no 
where "between" the UNWIND-PROTECT and the TAGBODY tag for control to be 
"going" that would leave the tag as a valid destination. A layer or 
three between them would provide that illusion, but I think it must be 
only an illusion, or at least indistinguishable from one in a conformant 
program. Right?

<D\'gou