[alexandria-devel] Re: UNWIND-PROTECT-CASE

Tobias C. Rittweiler tcr at freebits.de
Fri Mar 14 13:05:13 UTC 2008


"Attila Lendvai" <attila.lendvai at gmail.com> writes:

> i'd be happy to push this, but imho the extra argument is unnecessary.
> i understand that it is a tiny bit more flexible in rare situations
> like:
>
> (unwind-protect-case (aborted-p)
>         (random 42)
>       (:always (when aborted-p ...)))
>
> but those are mostly covered by the three :always, :normal, :abort cases.

It's not for this because you can write this one as

  (unwind-protect-case ()
          (...)
        (:always (do-something))
        (:abort  (handle-abort))
        (:always (do-something-else)))

It's for the case where you want to _delegate_ the work to a function:

  (unwind-protect-case (aborted-p)
          (...)
       (:always (perform-cleanup aborted-p ...)))

Where PERFORM-CLEANUP does different things depending on the ABORTED-P
flag. 

The reason for this is for the case where you want to use
UNWIND-PROTECT-CASE in a macroexpansion, and don't want to blow up the
macroexpansion with too much code.


> and it introduces an extra argument for unwind-protect-case which
> makes it look less like unwind-protect.

I actually consider it to be a feature because it's easier to
distinguish these two syntactically.

  -T.




More information about the alexandria-devel mailing list