GNU bug report logs -
#47677
[PATCH] condition-case success continuation
Previous Next
Reported by: Mattias Engdegård <mattiase <at> acm.org>
Date: Fri, 9 Apr 2021 20:28:02 UTC
Severity: wishlist
Tags: patch
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
Message #85 received at 47677 <at> debbugs.gnu.org (full text, mbox):
>
> 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.
This bug report was last modified 4 years and 18 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.