From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Newsgroups: gmane.emacs.bugs Subject: bug#25154: 25.1; Bindings in cl-letf are in reverse order Date: Fri, 09 Dec 2016 22:29:36 -0600 Message-ID: <87shpwbe4v.fsf@gmail.com> References: <8737hwllow.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1481344213 10449 195.159.176.226 (10 Dec 2016 04:30:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Dec 2016 04:30:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: 25154@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 10 05:30:08 2016 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 1cFZIV-0001kJ-P0 for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Dec 2016 05:30:08 +0100 Original-Received: from localhost ([::1]:50184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cFZIZ-0002nu-Ub for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Dec 2016 23:30:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cFZIT-0002gO-LV for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2016 23:30:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cFZIQ-0006mj-IV for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2016 23:30:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cFZIQ-0006mW-Fp for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2016 23:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cFZIQ-0001gC-6l for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2016 23:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Dec 2016 04:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25154-submit@debbugs.gnu.org id=B25154.14813441956422 (code B ref 25154); Sat, 10 Dec 2016 04:30:02 +0000 Original-Received: (at 25154) by debbugs.gnu.org; 10 Dec 2016 04:29:55 +0000 Original-Received: from localhost ([127.0.0.1]:36467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFZII-0001fW-Ud for submit@debbugs.gnu.org; Fri, 09 Dec 2016 23:29:55 -0500 Original-Received: from mail-io0-f194.google.com ([209.85.223.194]:34485) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFZIH-0001fI-DQ for 25154@debbugs.gnu.org; Fri, 09 Dec 2016 23:29:53 -0500 Original-Received: by mail-io0-f194.google.com with SMTP id y124so10829731iof.1 for <25154@debbugs.gnu.org>; Fri, 09 Dec 2016 20:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=QowZr5mFSDrHgW42kTamb5W+yDP+nkL2nwv6oqFK0ao=; b=tQgQyUQciIvuo0bbfPDL5XqKy0YiLM30MnFNMDzFo8KRiV+kSbPoRj/vx0Sa6tpyAw FdK/yjBwRCMuVhw1Db9g6gKzeCsWmVSkDeyG609+mCTkNP0RszJPttpdgRyYr2mAeR0I RDd90NHFKro9UPE0rYYNr3+Iq2WI1SZkdF8KQjiqVqj9F38XAl1cncVBQkNGeWrruxxe RBBIMLaTcSEGR9MG0dj0/ZuDOCPK8L2TKr/Pq8k1+dIUcvxxAFm4Li03555ACzPERLWV VTQpjxlw/XU4ntJ0eeat7SYuvE2QkEw2yKxP05BwzFCttXoBJSVVQhiVVAmLAGaeD+6m lhwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=QowZr5mFSDrHgW42kTamb5W+yDP+nkL2nwv6oqFK0ao=; b=AHCYgs8yD1N4xCofX8Ia3yVmPCqwrnQiV96BxbXkmw8mvVq+JB7mwAKLzJxVqd9lrf fxfryTCOuX8uwCe2Jj8y/IUkGZ3UXVnbuf4V29anxpbFKJFTpyIqWFSn1NcesaoafQXX 3/E1oLQoCpZDmqHPAv4lO6UePSR9Z0IEaUUSUV4hWfuvsXZdc262+h8z4qnqevY+DSI0 2cS4fXETaC2mzLEnXYFWINmmqsq4MgQ4ulga5zEm7N0YFXm5206wDs4WHeyKRVfO01u3 8L4RgBPbJB28glk4qcQUhHlcJlaac7G6QfA/FCH9Ra4PH6shv4jXxoN4/rnRqEYIpjJ5 AAEA== X-Gm-Message-State: AKaTC00H1KmdHd/6q3nqJyS0pJEMm6UOcDOrVE5EXp9hdYyJkpeS+sGxtNKOJsPN5x38qw== X-Received: by 10.36.64.75 with SMTP id n72mr1518739ita.105.1481344187567; Fri, 09 Dec 2016 20:29:47 -0800 (PST) Original-Received: from lylat (S01061859339e9903.ss.shawcable.net. [174.2.107.88]) by smtp.gmail.com with ESMTPSA id r207sm8294372iod.4.2016.12.09.20.29.46 for <25154@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Dec 2016 20:29:46 -0800 (PST) In-Reply-To: <8737hwllow.fsf@gmail.com> (Alex's message of "Fri, 09 Dec 2016 17:36:15 -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:126789 Archived-At: --=-=-= Content-Type: text/plain Alex writes: > Compare the following: > > (let ((x 5) > (x 6)) > (+ x 10)) > > => 16 > > (cl-letf ((x 5) > (x 6)) > (+ x 10)) > > => 15 > > > This also occurs when using non-trivial places: > > (setq v (vector 1 2 3 4 5)) > > (cl-letf (((aref v 1) 10) > ((aref v 1) 20)) > (aref v 1)) > > => 10 > > > I ran into this when using two different setters that sometimes > indirectly modify the same variable. The current behaviour makes the > result of that unexpected. I attached a patch that fixes this issue: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Preserve-the-order-of-bindings-in-cl-letf.patch Content-Description: cl-letf patch >From 9a74f1e7f8d8cc77b111473f8ee53e46af8a9957 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Fri, 9 Dec 2016 22:10:54 -0600 Subject: [PATCH] Preserve the order of bindings in cl--letf Do not reverse the order of the bindings in cl-letf (Bug #25154). * lisp/emacs-lisp/cl-macs.el (cl--letf): Use nreverse to restore the order of bindings. --- lisp/emacs-lisp/cl-macs.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 210a208..34f124f 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2388,7 +2388,10 @@ cl--letf ;; VAL1; VAL2; PLACE1; bind1; PLACE2; bind2 ;; Common-Lisp's `psetf' does the first, so we'll do the same. (if (null bindings) - (if (and (null binds) (null simplebinds)) (macroexp-progn body) + (if (and (null binds) (null simplebinds)) + (macroexp-progn body) + (setq binds (nreverse binds)) + (setq simplebinds (nreverse simplebinds)) `(let* (,@(mapcar (lambda (x) (pcase-let ((`(,vold ,getter ,_setter ,_vnew) x)) (list vold getter))) -- 2.10.2 --=-=-=--