From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#32803: 26.1.50; cl-do: Add more literature in docstring Date: Sat, 29 Sep 2018 05:13:57 +0900 Message-ID: <87lg7l752y.fsf@calancha-pc.dy.bbexcite.jp> 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538165588 2712 195.159.176.226 (28 Sep 2018 20:13:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2018 20:13:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32803@debbugs.gnu.org To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 28 22:13:03 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 1g5z8J-0000av-Md for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2018 22:13:03 +0200 Original-Received: from localhost ([::1]:45704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5zAQ-0003p1-5n for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2018 16:15:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5zAJ-0003mX-2l for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 16:15:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5zAE-0005vs-Fm for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 16:15:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53763) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5zAE-0005vZ-6I for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 16:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g5zAD-0004hm-Sd for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2018 16:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Sep 2018 20:15:01 +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.153816565118007 (code B ref 32803); Fri, 28 Sep 2018 20:15:01 +0000 Original-Received: (at 32803) by debbugs.gnu.org; 28 Sep 2018 20:14:11 +0000 Original-Received: from localhost ([127.0.0.1]:58021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5z9O-0004gN-Or for submit@debbugs.gnu.org; Fri, 28 Sep 2018 16:14:11 -0400 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:40017) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5z9N-0004g6-4f for 32803@debbugs.gnu.org; Fri, 28 Sep 2018 16:14:09 -0400 Original-Received: by mail-wr1-f44.google.com with SMTP id y8-v6so7606552wrh.7 for <32803@debbugs.gnu.org>; Fri, 28 Sep 2018 13:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YXDbuQ/QTQUyusrMSNKMvNddFiz2akN0BF/9Y2Qbg+U=; b=o0W8qInkcNnPMPfdolXOCW64iwcfL9pmJtowf8PqW1+3maNHq6GQ2DVTATB4ROfWs1 T2P6an9rNPSoDzretMc3l3AU/rW8tK5D+/UjBLKPyEcvrEpQQeSGw50SVJPfEGEOpP97 1Lp7sm1nBXECb7fBw4S8wUpifSzUoKP1F7TywrAz+zSNFwJoE+1IInK5cof9ZcQpgTW2 TS7CuhBGIds3gsbZTN2KsDaME1hBsddJcXEyXRQTtL5uLfSVXB6NTpi72pncPee6Hfc7 R4h4nPRIHIhoww5E7mTfsq3jamc9lNr4YciZlcwJIQjIlaVSHohEyr2jF7HyPGJxllue rMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=YXDbuQ/QTQUyusrMSNKMvNddFiz2akN0BF/9Y2Qbg+U=; b=k0dD59CL6ZCEbkaLufl7WcplhRuGAuF25y923ZhznwOuEeO8GZGo4a+6ecc/O05jy8 FG/8DZ7ztXR6TRyse6A00xOmft3l22iHxfvsmuihZOcQAtMIxPnjy/zmXGBhwa6lZ3VK HEJcWCxOnBU6nbKV4JKPgweEjqO8/Xz/dmeqwlWMfj0VPp2ALyO/4iCNjKJHVEqVmbVh whxYxoWcmIde2tLbB5/gSJ2VkIL97S3ErLacqYZZ30ORekkvxxCO9W+nqw+EKMi5H/4a SlGClrgZ2UgLXGuEVEe6WS9njvCK9U/kI0bOA2ea2GnlB0myYqz8ODNBVYy04j4TG6Cn /FDw== X-Gm-Message-State: ABuFfoi03lHg0Mq26elmWPV8dIqCyr5mlfNb8vtxvgntzwOX74hWlDkH 2kTGGr49A9SBCPtjlgy6HEUXRMw2GNA= X-Google-Smtp-Source: ACcGV62vu2CxhOq1riBTAyZzHjOlfEsOTUAyJ3Hp571+sG4VN2tNIGRw8uJH+w1bw5+kNh7YUrErRA== X-Received: by 2002:adf:f785:: with SMTP id q5-v6mr143164wrp.86.1538165643029; Fri, 28 Sep 2018 13:14:03 -0700 (PDT) Original-Received: from calancha-pc.dy.bbexcite.jp (15.red-83-50-151.dynamicip.rima-tde.net. [83.50.151.15]) by smtp.gmail.com with ESMTPSA id r13-v6sm2703426wmf.35.2018.09.28.13.14.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 13:14:02 -0700 (PDT) In-Reply-To: <87y3bnoa49.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Wed, 26 Sep 2018 21:08:38 -0700") 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:150741 Archived-At: 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: --8<-----------------------------cut here---------------start------------->8--- 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. 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. + For more details, see `cl-do' description in Info node `(cl) Iteration'. \(fn ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)" @@ -1785,6 +1788,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. + This is to `cl-do' what `let*' is to `let'. For more details, see `cl-do*' description in Info node `(cl) Iteration'. --8<-----------------------------cut here---------------end--------------->8---