From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Simplify internal_catch() Date: Tue, 27 Dec 2016 21:50:21 -0500 Message-ID: References: <87k2aku8bk.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1482893514 13549 195.159.176.226 (28 Dec 2016 02:51:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Dec 2016 02:51:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 28 03:51:51 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cM4LG-00031l-Ok for ged-emacs-devel@m.gmane.org; Wed, 28 Dec 2016 03:51:50 +0100 Original-Received: from localhost ([::1]:57095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cM4LL-0001GI-Ig for ged-emacs-devel@m.gmane.org; Tue, 27 Dec 2016 21:51:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cM4K7-0000tg-Fl for emacs-devel@gnu.org; Tue, 27 Dec 2016 21:50:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cM4K2-00005b-Dd for emacs-devel@gnu.org; Tue, 27 Dec 2016 21:50:39 -0500 Original-Received: from [195.159.176.226] (port=33843 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cM4K2-0008WD-6I for emacs-devel@gnu.org; Tue, 27 Dec 2016 21:50:34 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cM4Js-00011u-P9 for emacs-devel@gnu.org; Wed, 28 Dec 2016 03:50:24 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:3cJCM0a5JIO+lIsa4PSwUkdT/sI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210860 Archived-At: > --- 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