From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: plist-put: destructive? Date: Sat, 21 Jan 2017 09:13:02 -0800 (PST) Message-ID: References: <87mvelzgrr.fsf@ericabrahamsen.net> <8737gcxt4e.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1485018855 6305 195.159.176.226 (21 Jan 2017 17:14:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 21 Jan 2017 17:14:15 +0000 (UTC) To: Eric Abrahamsen , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 21 18:14:10 2017 Return-path: Envelope-to: geh-help-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 1cUzEb-0007uS-TF for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 18:13:50 +0100 Original-Received: from localhost ([::1]:60963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUzEf-0002MK-AM for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 12:13:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUzE8-0002ME-9z for help-gnu-emacs@gnu.org; Sat, 21 Jan 2017 12:13:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUzE4-000300-P8 for help-gnu-emacs@gnu.org; Sat, 21 Jan 2017 12:13:20 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:46327) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cUzE4-0002yx-FD for help-gnu-emacs@gnu.org; Sat, 21 Jan 2017 12:13:16 -0500 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0LHD45v006519 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 17:13:04 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v0LHD4Ke012447 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 17:13:04 GMT Original-Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v0LHD2hZ002514; Sat, 21 Jan 2017 17:13:03 GMT In-Reply-To: <8737gcxt4e.fsf@ericabrahamsen.net> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112138 Archived-At: > Thanks to you both. I'm working with existing plists, so I'll drop > the setqs, that's a relief. Why is it a relief - a relief from what? What if something reset your "exi= sting plist" to nil behind your back? Setting (again) a variable whose value is an object to which you've applied= a destructive operation is the standard idiom. And it is good programming= practice. It ensures that your code does what you expect, regardless of t= he object value, or rather, regardless of the effect of the operation. You naturally think of your variable as always pointing to the object that = you expect. To keep this relationship, you must set the variable to the re= turn value of any destructive operation. This is true for a possibly "destructive" operation on any kind of object. = The poster-child case is a list. See, for example, (elisp) `Rearrangement= ' (http://www.gnu.org/software/emacs/manual/html_node/elisp/Rearrangement.h= tml). The point is that your variable is otherwise not guaranteed to continue to = point to the object that you think it does. You need to set it to the _res= ult_ of the possibly destructive operation (the return value), if you reall= y want the variable to take the effect of that operation into account. This is all about the difference between a variable and its object value.