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
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
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
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
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 ***
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