From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#32803: 26.1.50; cl-do: Add more literature in docstring Date: Fri, 28 Sep 2018 14:00:50 -0700 Message-ID: <87ftxtl4l9.fsf@ericabrahamsen.net> References: <87y3bt7exx.fsf@calancha-pc.dy.bbexcite.jp> <83ftxzb6lx.fsf@gnu.org> <87pnx36vy2.fsf@calancha-pc.dy.bbexcite.jp> <87va6un8vu.fsf@ericabrahamsen.net> <83y3bqal3i.fsf@gnu.org> <87d0t2n5of.fsf@ericabrahamsen.net> <87y3bnoa49.fsf@ericabrahamsen.net> <87lg7l752y.fsf@calancha-pc.dy.bbexcite.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538168350 9861 195.159.176.226 (28 Sep 2018 20:59:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2018 20:59:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32803@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 28 22:59:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1g5zqq-0002Sd-Je for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2018 22:59:04 +0200 Original-Received: from localhost ([::1]:45822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5zsw-0007vx-Ve for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2018 17:01:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5zso-0007ut-Mt for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 17:01:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5zsk-0000kh-Lc for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 17:01:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5zsk-0000kc-Fm for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 17:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g5zsk-0005si-E1 for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 17:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Sep 2018 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32803 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32803-submit@debbugs.gnu.org id=B32803.153816845522586 (code B ref 32803); Fri, 28 Sep 2018 21:01:02 +0000 Original-Received: (at 32803) by debbugs.gnu.org; 28 Sep 2018 21:00:55 +0000 Original-Received: from localhost ([127.0.0.1]:58050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5zsc-0005sE-Un for submit@debbugs.gnu.org; Fri, 28 Sep 2018 17:00:55 -0400 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:52684) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5zsb-0005s6-3O for 32803@debbugs.gnu.org; Fri, 28 Sep 2018 17:00:53 -0400 Original-Received: from localhost (50-251-205-17-static.hfc.comcastbusiness.net [50.251.205.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 397C6C5011; Fri, 28 Sep 2018 21:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1538168452; bh=lzmV5P4Saxkwi8Z8gKvcsIpyBFshuyKywxwLz10sLq8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=AjQTe6Y3WzoyPSZ/cjDsVPElfSXZo6TD5Pwiuak1zInQ1Kb6uzg289mBpWm7isUM9 fA0//uoejq/jBVpeSoasuHeXCME4vcaGgj5ahR2OT1Il+keGcMAdfYJb39OsZYdb7E NTP0eUWm/zVztAi3mOLxyYNxpPcBDTmwRcDZXmN0= In-Reply-To: <87lg7l752y.fsf@calancha-pc.dy.bbexcite.jp> (Tino Calancha's message of "Sat, 29 Sep 2018 05:13:57 +0900") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:150743 Archived-At: Tino Calancha writes: > Eric Abrahamsen writes: > >>> I am OK to rephrase it to make it more obvious if you have something >>> in mind. >> >> I don't have a serious objection! It just seems to me that the key >> question about any test-and-loop construct is: does it test first, or >> loop first? As Eli points out, the rest of the docstring makes it clear >> that it tests first. It just seems to me that nothing is lost (and >> something gained) by replacing "in" with "before". > Thank you Eric. > I agree with you that such info is crucial. Indeed, in my first > version of the patch I included the line: > "On each iteration, check END-TEST before run BODY." > > I think is worth to remark that. > Following patch applies on top of the previous one: Thanks for doing this! I have nitpicks :) > commit c057715eff519114e38d82d39b16d8f2a01c3c4d > Author: Tino Calancha > Date: Sat Sep 29 05:05:59 2018 +0900 > > Clarify that ENDTEST belongs to the iteration > > diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el > index 10bc611325..b02a917ac0 100644 > --- a/lisp/emacs-lisp/cl-macs.el > +++ b/lisp/emacs-lisp/cl-macs.el > @@ -1747,10 +1747,9 @@ cl--loop-build-ands > (defmacro cl-do (steps endtest &rest body) > "Bind variables and run BODY forms until END-TEST returns non-nil. > First, each VAR is bound to the associated INIT value as if by a `let' form. > -Then, in each iteration of the loop, the END-TEST is evaluated; if true, > -the loop is finished. Otherwise, the BODY forms are evaluated, then each > -VAR is set to the associated STEP expression (as if by a `cl-psetq' > -form) and the next iteration begins. > +Then, the END-TEST is evaluated; if true, the loop is finished. Otherwise, > +the BODY forms are evaluated, then each VAR is set to the associated > +STEP expression (as if by a `cl-psetq' form) and the next iteration begins. The variable name is endtest, so I guess should be ENDTEST here (no hyphen), the same way you've got it later on. > Once the END-TEST becomes true, the RESULT forms are evaluated (with > the VARs still bound to their values) to produce the result > @@ -1759,6 +1758,10 @@ cl-do > Note that the entire loop is enclosed in an implicit `nil' block, so > that you can use `cl-return' to exit at any time. > > +Also note that the ENDTEST belongs to the iteration; it's always checked > +before evaluate BODY. In particular, if ENDTEST evaluates initially non-nil, > +the `cl-do' will end without running BODY. Some tiny edits here and in the cl-do* docstring: Also note that ENDTEST is checked before evaluating BODY. If ENDTEST is initially non-nil, `cl-do' will exit without running BODY. That's pretty pedantic, but I'm an editor and can't help it :) Thanks for your clarification of these docs! Eric