Subject: bug#47677: [PATCH] condition-case success continuation

From: Mattias Engdegård <[email-masked]>
Date: Sat, 24 Apr 2021 19:02:07 +0200

23 apr. 2021 kl. 06.18 skrev Richard Stallman <[email-masked]>:

> catch and throw are ok
> as they are, and we should leave them alone.

And so we do! All we do here is to fill a few gaps in the system, but if you don't feel the need for it then you can just ignore that the new construct exist.

See the previous discussion for examples, but your code is also a good illustration:

>  (if (catch 'foo
>         (prog1 nil
>            ...do stuff...))  ;; use (throw 'foo t) to exit
>      do-if-throw
>     do-if-no-throw)

Here the throw transmits no useful value at all; if it did, this value would have to be restricted in some way, such as being non-nil. The Lisp implementation knows very well whether a throw occurred or not, so we can expose that information instead of having the user hack around the limitation.

Common uses of catch/throw include early exits from deep searches when a match is found, and then it is useful that the thrown value is unrestricted. Conversely, when `throw` is used to indicate a failure, it is useful to have the normal return value unrestricted.

The patch does not include the required documentation changes; naturally that will be remedied.