[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lisp unwind-protect question
From: |
Kevin Rodgers |
Subject: |
Re: lisp unwind-protect question |
Date: |
Wed, 06 Mar 2002 11:12:49 -0700 |
phr-2002@nightsong.com wrote:
>
> The doc string for unwind-protect says:
>
> Do BODYFORM, protecting with UNWINDFORMS.
> Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).
> If BODYFORM completes normally, its value is returned
> after executing the UNWINDFORMS.
> If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
Yeah, the usage would be better described as
(unwind-protect PROTECTED-FORM UNWIND-FORM ...) or
(unwind-protect PROTECTED-FORM UNWIND-FORM-1 ... UNWIND-FORM-N)
since the unwind forms comprise an implicit progn.
> So if you say
>
> (unwind-protect
> (foo)
> (bar)
> (baz))
>
> What's supposed to happen if (bar) signals an error? Does (baz) still
> get run?
No, only the BODYFORM (foo) is protected.
> What if bar doesn't signal an error by itself, but some asynchronous
> signal arrives (e.g. user hits C-g) while bar is running?
Same thing: evaluation is terminated.
> How do Lisp systems in general (not just Emacs Lisp) deal with this
> situation? I guess it's easy for me to check Emacs Lisp's behavior by
> experiment, but it's the general question about other Lisps that
> interests me most.
Common Lisp defines the unwind-protect special form with the same syntax
and semantics as the Emacs Lisp built-in.
> I hope this isn't too off-topic for this list.
Followup-To: gnu.emacs.help
You should probably post your general question to comp.lang.lisp
--
Kevin Rodgers <kevinr@ihs.com>