From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Define progn_ignore to run Fprogn and ignore output Date: Tue, 27 Dec 2016 15:49:47 +0000 Message-ID: <20161227154947.GA2324@acm.fritz.box> References: <871swum82w.fsf@CzipperZag.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1482853871 5424 195.159.176.226 (27 Dec 2016 15:51:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2016 15:51:11 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: emacs-devel@gnu.org To: Chris Gregory Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 27 16:51:07 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 1cLu1p-0000kq-Gd for ged-emacs-devel@m.gmane.org; Tue, 27 Dec 2016 16:51:05 +0100 Original-Received: from localhost ([::1]:54663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLu1u-0000lZ-7Y for ged-emacs-devel@m.gmane.org; Tue, 27 Dec 2016 10:51:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLu10-0000Bt-NB for emacs-devel@gnu.org; Tue, 27 Dec 2016 10:50:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLu0x-00039X-M0 for emacs-devel@gnu.org; Tue, 27 Dec 2016 10:50:14 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:53401 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1cLu0x-00037L-Fy for emacs-devel@gnu.org; Tue, 27 Dec 2016 10:50:11 -0500 Original-Received: (qmail 77537 invoked by uid 3782); 27 Dec 2016 15:50:08 -0000 Original-Received: from acm.muc.de (p548C7014.dip0.t-ipconnect.de [84.140.112.20]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 27 Dec 2016 16:50:08 +0100 Original-Received: (qmail 2401 invoked by uid 1000); 27 Dec 2016 15:49:47 -0000 Content-Disposition: inline In-Reply-To: <871swum82w.fsf@CzipperZag.i-did-not-set--mail-host-address--so-tickle-me> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 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:210841 Archived-At: Hello, Chris. Just a small point about your proposed patch. On Mon, Dec 26, 2016 at 08:14:47PM -0600, Chris Gregory wrote: > This patch defines progn_ignore to do Fprogn but not return a result. > This will minorly speed up all operations using `unwind_body'. It also > simplifies the code for `Fprog1' without sacrificing performance. > diff --git a/src/eval.c b/src/eval.c > index ddcccc2..7e02838 100644 > --- a/src/eval.c > +++ b/src/eval.c > @@ -456,10 +456,17 @@ usage: (progn BODY...) */) > /* Evaluate BODY sequentially, discarding its value. Suitable for > record_unwind_protect. */ > +static void > +progn_ignore (Lisp_Object body) > +{ > + while (CONSP (body)) > + eval_sub (XCAR (body)); > +} > + Doesn't the above code up an infinite loop? `body' appears not to be changed between iterations of the while. > void > unwind_body (Lisp_Object body) > { > - Fprogn (body); > + progn_ignore (body); > } > DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, > @@ -470,15 +477,8 @@ usage: (prog1 FIRST BODY...) */) > (Lisp_Object args) > { > Lisp_Object val; > - Lisp_Object args_left; > - > - args_left = args; > - val = args; > - > - val = eval_sub (XCAR (args_left)); > - while (CONSP (args_left = XCDR (args_left))) > - eval_sub (XCAR (args_left)); > - > + val = eval_sub (XCAR (args)); > + progn_ignore (XCDR (args)); > return val; > } -- Alan Mackenzie (Nuremberg, Germany).