all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Stefan Kangas <stefan@marxist.se>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	47677@debbugs.gnu.org
Subject: bug#47677: [PATCH] condition-case success continuation
Date: Mon, 26 Apr 2021 13:53:26 +0200	[thread overview]
Message-ID: <0CE64301-EF9E-4351-8CFC-6DD272B2B230@acm.org> (raw)
In-Reply-To: <87wnsql3dg.fsf@gnus.org>

25 apr. 2021 kl. 18.45 skrev Lars Ingebrigtsen <larsi@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.






  reply	other threads:[~2021-04-26 11:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 20:26 bug#47677: [PATCH] condition-case success continuation Mattias Engdegård
2021-04-10 23:52 ` Stefan Monnier
2021-04-11 11:13   ` Mattias Engdegård
2021-04-12  8:49     ` Lars Ingebrigtsen
2021-04-12 15:10       ` Stefan Monnier
2021-04-12 19:20         ` Mattias Engdegård
2021-04-13  7:38           ` Lars Ingebrigtsen
2021-04-13  8:52             ` Mattias Engdegård
2021-04-14  9:29               ` Lars Ingebrigtsen
2021-04-15 13:54                 ` Mattias Engdegård
2021-04-16  5:13                   ` Richard Stallman
2021-04-16  5:13                   ` Richard Stallman
2021-04-21 14:13                   ` Stefan Kangas
2021-04-22 13:58                     ` Mattias Engdegård
2021-04-23  4:18                       ` Richard Stallman
2021-04-24 17:02                         ` Mattias Engdegård
2021-04-25  4:44                           ` Richard Stallman
2021-04-25  7:35                             ` Eli Zaretskii
2021-04-25 18:21                               ` bug#47677: [External] : " Drew Adams
2021-04-25 18:24                                 ` Eli Zaretskii
2021-04-26  4:40                               ` Richard Stallman
2021-04-26 12:44                                 ` Eli Zaretskii
2021-04-27  3:46                                   ` Richard Stallman
2021-04-26 15:12                           ` Filipp Gunbin
2021-04-27 15:31                             ` Mattias Engdegård
2021-04-27 19:00                               ` Gregory Heytings
2021-04-29 12:45                               ` Filipp Gunbin
2021-04-25 16:45                       ` Lars Ingebrigtsen
2021-04-26 11:53                         ` Mattias Engdegård [this message]
2021-04-27  3:46                           ` Richard Stallman
2021-04-26 21:57 ` Gregory Heytings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0CE64301-EF9E-4351-8CFC-6DD272B2B230@acm.org \
    --to=mattiase@acm.org \
    --cc=47677@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.