From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#6583: 23.2; cl loop macro with `and' clause Date: Sat, 24 Jun 2017 20:22:09 -0400 Message-ID: <87injkq5la.fsf@users.sourceforge.net> References: <871vbedfzq.fsf@blah.blah> <87d1abu09j.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1498350075 16961 195.159.176.226 (25 Jun 2017 00:21:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Jun 2017 00:21:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 6583@debbugs.gnu.org, Kevin Ryde To: Alex Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 25 02:21:11 2017 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 1dOvIb-00046H-89 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Jun 2017 02:21:09 +0200 Original-Received: from localhost ([::1]:40803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOvIg-00039f-Hu for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Jun 2017 20:21:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOvIX-000389-Pl for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2017 20:21:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOvIU-0003vt-Ea for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2017 20:21:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dOvIU-0003vd-8z for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2017 20:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dOvIT-0000Sr-WB for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2017 20:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Jun 2017 00:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6583 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed patch Original-Received: via spool by 6583-submit@debbugs.gnu.org id=B6583.14983500401745 (code B ref 6583); Sun, 25 Jun 2017 00:21:01 +0000 Original-Received: (at 6583) by debbugs.gnu.org; 25 Jun 2017 00:20:40 +0000 Original-Received: from localhost ([127.0.0.1]:36099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOvI8-0000S4-Fh for submit@debbugs.gnu.org; Sat, 24 Jun 2017 20:20:40 -0400 Original-Received: from mail-io0-f195.google.com ([209.85.223.195]:35164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOvI6-0000Rr-GL for 6583@debbugs.gnu.org; Sat, 24 Jun 2017 20:20:39 -0400 Original-Received: by mail-io0-f195.google.com with SMTP id 84so4472694iop.2 for <6583@debbugs.gnu.org>; Sat, 24 Jun 2017 17:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vPeHTfKL4qv58K4jCAeq1m8/npZyV9X3u5AjIRpEvHs=; b=oZwW+mrv53hDF6MzUBGSSfomEauXft0l5TueSlMc0puixDd+I0ODCRuf5hHwZ2luPM 99UkbD8tSjh7ZGSWWMS66Hhjp4zforxq/fAibbnedFyoU2nayKc4SvWixccVFvFgB0Jf mtFmx6cYP0/rwN2yeo7S8coCcnME2YcZLaQ0VtYvgt65ssHjED3PjTaXP7alGiyKPdzz lD5Dmr+pbhbBLHj5s4RU+XG0BZ+prSMtmqGIYA7awTIdQvWjMzl6FEkQspmA4CMYFhwZ Ox0Hbuf4zO9+x629/3BY+FnwRr69DzGKgCMU2FjbE3XCce9BtkClM5IQUNvDxpc7tyj+ 1DBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=vPeHTfKL4qv58K4jCAeq1m8/npZyV9X3u5AjIRpEvHs=; b=gcb4xkZqVfQPzk+v6d1YfZ1jsnPY3B9ec6GgxoolPbpa+uScRf5rTDVV6j1C46jjIw IE3xCYF5G8uN55EmupeqlgfbDMLArGL9ydVNtoJonGdg39j9U+vLKJOITexQNG3la3x1 GehbSBwp7BpWJojFA1DEkLnPV3EiymNW0rs6G+TpSg7tdEnyAbwnVboyxob3y/zaXDTq hejKNhm7lI/RyZjKbE9gFlgbvVzxPxL2PYE1mvDliiYm0aGda7Kfw52l0aEpGOAynWSF zx+DvqHNYYiL4dKMB1ERCtmZH8eR5mfa6qV749P62EL71vZO+1K6Pe9y+/MEjNUwAp4W NDbA== X-Gm-Message-State: AKS2vOwVrYmne4pRlQEuSLgn7nogGZNk/6yOwAYQ5i2YV8WoYq7vdsBQ KiM10hSwI3C9loTO X-Received: by 10.107.62.132 with SMTP id l126mr4550723ioa.162.1498350032660; Sat, 24 Jun 2017 17:20:32 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id j21sm5375709itb.15.2017.06.24.17.20.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Jun 2017 17:20:31 -0700 (PDT) In-Reply-To: <87d1abu09j.fsf@gmail.com> (Alex's message of "Sat, 10 Jun 2017 13:10:32 -0600") 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:133857 Archived-At: Alex writes: > > This problem appears to have been present even in the initial revision > (fcd737693e8), specifically in the (eq word '=) clause. > > I see no reason for the (or ands (eq (car args) 'and)) consequent, as > what it does when it detects an 'and is: > > * In the first iteration, set var (k) to the first form (elem) at the > beginning of the iteration > > * In subsequent iterations, set var (k) to itself at the beginning of > the iteration (noop) > > * At the end of every iteration, set var (k) to the second form > (defaulting to the first form, elem). > > The last point is the main problem: you can't set the variable to the > first form at the end of the iteration as it might depend on other loop > variables (in this case elem) that are updated at the beginning of the > iteration. > > I've attached a patch below that appears to solve this issue. With the > patch, var is set to the first or second form at the beginning of the > iteration (just like it is when no 'and is present). I can't claim to fully understand the loop macro implementation, but your patch breaks this example from the manual `(cl) For Clauses': (cl-loop for x below 5 for y = nil then x collect (list x y)) => ((0 nil) (1 1) (2 2) (3 3) (4 4)) (cl-loop for x below 5 and y = nil then x collect (list x y)) => ((0 nil) (1 0) (2 1) (3 2) (4 3)) With your patch the second loop gives ((0 nil) (1 1) (2 2) (3 3) (4 4)) like the first.