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
View this message in rfc822 format
25 apr. 2021 kl. 18.45 skrev Lars Ingebrigtsen <larsi <at> gnus.org>:
> condition-case is about handling errors -- it can be used as a general
> flow control system, but that's an awkward fit. It conveys intention.
> So I don't think we should extend it to handle more throw/catch-like
> things.
Most other languages use the same exception system for both errors and 'throws'; the distinction in Lisp is an artefact of history. Both are dynamically-scoped single-shot upwards-only value-conveying non-local control transfers (or described in continuation terms with about as many adjectives). The differences are minor.
Several times I've had to hack around the inability of `catch` to distinguish throws from normal termination and could go on doing so, but it feels like making function calls by manual variable assignment, stack operations and jumps. The byte code has no trouble expressing a more useful catch; it's just an arbitrary restriction in our Lisp primitives.
In addition, `catch` and `condition-case` don't compose. It would be interesting to design primitives that do but since that seems tricky (prove me wrong!), a unified `condition-case` does the job with a minimum of fuss and is definitely not a hack.
> However, I do agree that Emacs Lisp could need some beefing up in the
> "early return" department
Yes! But catch/throw is good for getting out of deep function call chains which is not quite the same thing. They are hard to optimise well for local use (exiting a loop or function) because it is difficult to prove the absence of throws elsewhere.
A variant of block/return-from would do, but better optimisations for local functions (TCO in particular) may be at least as useful.
This bug report was last modified 4 years and 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.