From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#35546: 27.0.50; setf return value for new alist entries is wrong Date: Sun, 12 Apr 2020 14:26:52 +0200 Message-ID: <87blnwdh4j.fsf@gmail.com> References: <87lfznzm08.fsf@gnu.org> <87ftpqmrz9.fsf@web.de> <878svimlbz.fsf@web.de> <85zhnyxqey.fsf@gmail.com> <8736lqmf5p.fsf@web.de> <85woj2xl7l.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="49025"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Michael Heerdegen , 35546@debbugs.gnu.org, Tassilo Horn To: npostavs@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 12 14:27:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jNbhf-000Ced-CX for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Apr 2020 14:27:11 +0200 Original-Received: from localhost ([::1]:33162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNbhe-0005HM-CD for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Apr 2020 08:27:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53355) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNbhX-0005HD-2m for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 08:27:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jNbhW-00046b-0o for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 08:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jNbhV-00046V-U5 for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 08:27:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jNbhV-00073m-RT for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 08:27:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Apr 2020 12:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35546 X-GNU-PR-Package: emacs Original-Received: via spool by 35546-submit@debbugs.gnu.org id=B35546.158669438627095 (code B ref 35546); Sun, 12 Apr 2020 12:27:01 +0000 Original-Received: (at 35546) by debbugs.gnu.org; 12 Apr 2020 12:26:26 +0000 Original-Received: from localhost ([127.0.0.1]:57487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNbgw-00072x-DO for submit@debbugs.gnu.org; Sun, 12 Apr 2020 08:26:26 -0400 Original-Received: from mail-lj1-f181.google.com ([209.85.208.181]:40116) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNbgt-00072k-Sb for 35546@debbugs.gnu.org; Sun, 12 Apr 2020 08:26:24 -0400 Original-Received: by mail-lj1-f181.google.com with SMTP id y4so28648ljn.7 for <35546@debbugs.gnu.org>; Sun, 12 Apr 2020 05:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=RA0JV67xj701SJPVxYB07Jj0Nz+sSvXdqKG8//Tyw7A=; b=W4MPhT3DYjrgCu4d34/wd8IFpn8psZuRudkJf0vn2A/aVpziwXAhp9QNoYOPa8n/DC SR+QBcT4b9zftcg951FWFEbb82Nw0VaYwWHEU96frQi6iSAFy5M+iMSukvIviwMqsrYk C1QmSDeJ3k7PysmcegfaPVuoV9CtgyYElDUOoW3Hto/u9NOF8dtKwtJi5N+sVnX/fvgg mUWZ/lqQmHk4GapHWUEsTopFseeScUttL1b6YJYuddcQ0nmCwI9hxVurAGCdwb1y/IsJ bUr7lyby9kTnjCzKgOn0xIdSnsIzdHOHMucxSbTrmnhoNp7CxcQ03Oj1xSvKVbt07wVu upSg== 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:in-reply-to:references :user-agent:date:message-id:mime-version; bh=RA0JV67xj701SJPVxYB07Jj0Nz+sSvXdqKG8//Tyw7A=; b=dvIpdhnR2bVLnfC3bwyKmDmukHXMMdhJ43un1CEf/aXs16ahVxNe+hbrfO0wYiK56k mnXXmporp1K8R4eySs2ZuVe/eBblfqzB7MauYssHkUGpNpKX1bifBr4T0adFtOu81Tnt 1KHsGTnC0pjjoTFWUcDcjlrlTc5cHg+BH4rCC2NXTcAmwGQDEMLJlOI7gknp+zKt2yeL oPjOmsn4DVwqRQohanxcjf3SwpU3hRJ/MDHjbiFJvRReSh3nCJPQS1MAOTY1NWfGHmob tMoqEPfG7QCHLbttLSkLRT7zNcOseVvw/oQVMPEm5uc5Yf0Au7xSGBorcyQ4HLCpc1Ff xADQ== X-Gm-Message-State: AGi0PuarZZB17H7FGanobZ1Gs+1s3GzyHZJPMZ3XASv8HdvIUIXU9Fy6 48JjExSOCZQ41MmSDZ8Wo/Q= X-Google-Smtp-Source: APiQypIxk48+RTn9TJPxzvYxmjl0wFjR1Q27WWIWH5GIlz1SOn7arNlkZYjzPThlENRoTTrnxTDt8g== X-Received: by 2002:a2e:a40d:: with SMTP id p13mr7531796ljn.264.1586694377830; Sun, 12 Apr 2020 05:26:17 -0700 (PDT) Original-Received: from localhost ([185.112.167.47]) by smtp.gmail.com with ESMTPSA id v22sm5218687ljc.79.2020.04.12.05.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 05:26:17 -0700 (PDT) In-Reply-To: <85woj2xl7l.fsf@gmail.com> (npostavs@gmail.com's message of "Tue, 07 May 2019 12:50:38 -0400") 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178239 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 35546 + patch thanks On Tue, 07 May 2019 12:50:38 -0400 npostavs@gmail.com wrote: > Michael Heerdegen writes: > >>> (setf (logand PLACE #x0F) V) > >> Anyway, there is no reason that the setter currently does not >> return V, right? > > I can't see any compelling reason to return the whole PLACE value after > update, so I guess it's just oversight. So yeah, it should return V > just like the setters for `cl-subseq' and `nth' return the new value, > not the whole sequence. I noticed `substring' had the same problem. Patch fixing that, together with cond and logand, attached. --=20 =C5=A0t=C4=9Bp=C3=A1n --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Preserve-setf-semantics-in-substring-cons-logand-exp.patch >From 90fcc412e85716ff348c3cc6fdcc06eb08b1f6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Sun, 12 Apr 2020 00:27:51 +0200 Subject: [PATCH] Preserve setf semantics in 'substring', 'cons', 'logand' expanders * doc/lispref/variables.texi (Adding Generalized Variables): Fix example. * lisp/emacs-lisp/cl-lib.el (substring) * lisp/emacs-lisp/gv.el (cons, logand): Return the value being assigned, as specified for 'setf'. (bug#35546) --- doc/lispref/variables.texi | 7 +++++-- lisp/emacs-lisp/cl-lib.el | 7 +++++-- lisp/emacs-lisp/gv.el | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index abcd4bbd0f..94c8c88796 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2585,8 +2585,11 @@ Adding Generalized Variables (macroexp-let2* nil ((start from) (end to)) (funcall do `(substring ,getter ,start ,end) (lambda (v) - (funcall setter `(cl--set-substring - ,getter ,start ,end ,v)))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter `(cl--set-substring + ,getter ,start ,end ,v)) + ,v)))))))) @end example @end defmac diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index 7a26d9a90f..7a4d3c9c3e 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -619,8 +619,11 @@ substring (macroexp-let2* nil ((start from) (end to)) (funcall do `(substring ,getter ,start ,end) (lambda (v) - (funcall setter `(cl--set-substring - ,getter ,start ,end ,v)))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter `(cl--set-substring + ,getter ,start ,end ,v)) + ,v)))))))) ;;; Miscellaneous. diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 065a968877..aa1516cc5e 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -517,9 +517,12 @@ gv-delay-error (gv-letplace (dgetter dsetter) d (funcall do `(cons ,agetter ,dgetter) - (lambda (v) `(progn - ,(funcall asetter `(car ,v)) - ,(funcall dsetter `(cdr ,v))))))))) + (lambda (v) + (macroexp-let2 nil v v + `(progn + ,(funcall asetter `(car ,v)) + ,(funcall dsetter `(cdr ,v)) + ,v)))))))) (put 'logand 'gv-expander (lambda (do place &rest masks) @@ -529,9 +532,12 @@ gv-delay-error (funcall do `(logand ,getter ,mask) (lambda (v) - (funcall setter - `(logior (logand ,v ,mask) - (logand ,getter (lognot ,mask)))))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter + `(logior (logand ,v ,mask) + (logand ,getter (lognot ,mask)))) + ,v)))))))) ;;; References -- 2.26.0 --=-=-=--