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

From: Gregory Heytings <[email-masked]>
Date: Mon, 26 Apr 2021 21:57:46 +0000

>
> This patch adds the condition-case handler syntax
>
>  (:success BODY)
>
> for code executed when the protected form terminates without error. BODY 
> is then executed with the variable bound to the result of the protected 
> form, and the result of BODY is then the value of the condition-case 
> form as usual.
>
> This plugs an annoying hole in elisp: there hasn't been any direct 
> access to the success continuation
>

Would a macro not be enough to cover that particular programming pattern? 
E.g. something like:

(defmacro success-case (value action continuation &rest handlers)
   `(catch 'success-case-fail
      ((lambda (,value) ,continuation)
       (catch 'success-case-success
         (throw 'success-case-fail
                (condition-case ,value
                    (throw 'success-case-success ,action) ,@handlers))))))

With this macro you can write for example:

(success-case result
     (read buffer)
   (use result)
   (end-of-file 'eof))

which is IMO even more concise and elegant.