all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Simplify internal_catch()
Date: Tue, 27 Dec 2016 21:50:21 -0500	[thread overview]
Message-ID: <jwveg0s7oud.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 87k2aku8bk.fsf@gmail.com

> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -458,7 +458,11 @@ usage: (progn BODY...)  */)
>  void
>  prog_ignore (Lisp_Object body)
>  {
> -  Fprogn (body);
> +  while (CONSP (body))
> +    {
> +      eval_sub (XCAR (body));
> +      body = XCDR (body);
> +    }
>  }

Why bother?  This is not performance-critical code, so the most
important criterion is to make the code clear and reduce redundancy.

> THE DIFF FOR THIS PATCH is in the attachments.

Both patches are identical, right?

> -  struct handler *c = push_handler (tag, CATCHER);
> +  struct handler *c;
> +  Lisp_Object val;
> +
> +  c = push_handler (tag, CATCHER);

Why place the declaration of `val` between the two?  I always strongly prefer
initializing a var directly in its declaration so that you simply cannot
refer to it in an uninitialized state.  Even more so for a variable
which is never modified afterwards.

>    if (! sys_setjmp (c->jmp))
> -    {
> -      Lisp_Object val = func (arg);
> -      clobbered_eassert (handlerlist == c);
> -      handlerlist = handlerlist->next;
> -      return val;
> -    }
> +    /* Call FUNC.  */
> +    val = func (arg);
>    else
> -    { /* Throw works by a longjmp that comes right here.  */
> -      Lisp_Object val = handlerlist->val;
> -      clobbered_eassert (handlerlist == c);
> -      handlerlist = handlerlist->next;
> -      return val;
> -    }
> +    /* Throw works by a longjmp that comes right here.  */
> +    val = handlerlist->val;
> +  clobbered_eassert (handlerlist == c);
> +  handlerlist = handlerlist->next;
> +  return val;

Right: sharing the tail is a good idea, thanks.


        Stefan




  reply	other threads:[~2016-12-28  2:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-28  1:54 Simplify internal_catch() Chris Gregory
2016-12-28  2:50 ` Stefan Monnier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-28  6:33 Chris Gregory
2016-12-28  8:48 ` Andreas Schwab
2016-12-28 16:45 ` Stefan Monnier
2016-12-28 19:24   ` Paul Eggert
2016-12-28 19:28     ` Stefan Monnier
2016-12-31 21:29       ` Paul Eggert
2016-12-28  7:34 [no subject] Chris Gregory
2016-12-28  7:42 ` Simplify internal_catch () Paul Eggert

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=jwveg0s7oud.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /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.