From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: Help with recursive destructive function Date: Tue, 05 Jun 2018 02:23:53 +0200 Message-ID: <87in6yw06e.fsf@web.de> References: <87efiqzzd2.fsf@ericabrahamsen.net> <87bmdu3mtf.fsf@web.de> <87zi1e9kju.fsf@web.de> <87o9hs3aht.fsf@ericabrahamsen.net> <87bmds9qcg.fsf@web.de> <87k1sg185t.fsf@ericabrahamsen.net> <044bdbf1-39a2-0e71-ec79-3d375d9109c8@gmail.com> <877eof1k7y.fsf@ericabrahamsen.net> <87wowe2sql.fsf@web.de> <877eoe2dma.fsf@ericabrahamsen.net> <87tvrgqnug.fsf@web.de> <87vabvbfrj.fsf@web.de> <87d0y30wkn.fsf@ericabrahamsen.net> <878t8mtiqz.fsf@web.de> <87vaayp4p8.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1528158174 5764 195.159.176.226 (5 Jun 2018 00:22:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 00:22:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eric Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 05 02:22:50 2018 Return-path: Envelope-to: ged-emacs-devel@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 1fPzkP-0001N1-Ss for ged-emacs-devel@m.gmane.org; Tue, 05 Jun 2018 02:22:49 +0200 Original-Received: from localhost ([::1]:42446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPzmV-0005yb-IH for ged-emacs-devel@m.gmane.org; Mon, 04 Jun 2018 20:24:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPzll-0005yH-F1 for emacs-devel@gnu.org; Mon, 04 Jun 2018 20:24:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPzli-0007ut-Bi for emacs-devel@gnu.org; Mon, 04 Jun 2018 20:24:13 -0400 Original-Received: from mout.web.de ([217.72.192.78]:44811) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPzli-0007uF-2S for emacs-devel@gnu.org; Mon, 04 Jun 2018 20:24:10 -0400 Original-Received: from drachen.dragon ([188.110.196.170]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MGign-1fU8dP36LR-00DV28; Tue, 05 Jun 2018 02:23:54 +0200 In-Reply-To: <87vaayp4p8.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Mon, 04 Jun 2018 15:28:03 -0700") X-Provags-ID: V03:K1:8JDaN5SgZJEkQwOOgPbWCEsl/kRSTRvqkxeuivYYcRD6v+hDLn8 68eaULYSbCmNBhihTLk2Szp3WyZws9WCFMFAuKIYJEozwL9njnzeRx9ivQX8kiJ8NPO22v0 ipSIvyICSURGwkXkd9+5rHyFwwnTdr3JG7j9vA5VEUVkNLBr5xO0Phl3hOD68KpxCViI2Kg 2Lf2tweJPG3vjvcwj03ww== X-UI-Out-Filterresults: notjunk:1;V01:K0:Rtpy4El6600=:Skw/TO3r/DtrABV1C8GIVh Eyrz9AbxEWm3H7BCc9Sy7zXbLMghfZ1jKySXMN7I2U1w/vYz8ZGK98z+il7Mdgbuge4icghKH wpqFzKNp+k8frXKSiH+yN1S6EgcFx4yqO0T7COLNLq9csIoO2RFHWVxhWGesA992oVMFH0i/e jsFCQ+rMQB6DJU3ebTz2tZLVQbY/szrVMRRyflhpXrhBFm7SYtk7yY01Jrui+gggnQKH+RUpG /bNPcXOp+T7cGo18n+LSnSBi0Tblmlrcrj2wFWsU3VpAYbVNs4VhdbBIuIrR0gcUbRAUiKS4t NygubGEoEkM7MCCKAQYbjxMatiDnag6nHozXl++XdHGPmVjH3DTOJnDqyhoEXpsI07XEWwfpn mYFCawZk1gUprsm5x4Xj78e1Q0B17B1B+yF6a8tGqGD0HbAMgx8kKIIUk7nD2dNXZngWHHj46 Ja0AKQecm1DlgXNDY2v3lExKAdU0YKrI3xqtfwu26gxEn5Nf4zMeWx2Iu5PdQR2sGlIW9aK64 d5ZdANoYWGY6ltmSqZ5cqbzmwGongi6H68Vykjp54SKmCg/USfYzisy3hyplmOxRsJ5W6XDV9 zFGUnLzdvP/JIC3dADOoubXg7AurPxsJivNxuN39K6M8n0z2QY/25G+xddg8lqTbbpnmonRvS 3IMRhqSM9fexQ39NxMXgklDaXvZt/N5gPtgx5FEqMBRM2xY2exyg244vPvBLFS4pZcXlINkVu tKZLHqTab55HXW7+Wsy4l/gCJjsUu2Spm6sGp6gNft7c/66y7s5kV8RRMKXbAgf/ML6217x+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.78 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226017 Archived-At: Eric Abrahamsen writes: > [...] > That only worked for consp values. I don't understand this: `nth' is > implemented in C as (car (nthcdr)), and nthcdr looks to me like it's > producing a chunk of the underlying list structure. So does car of > nthcdr return a simple value (ie something un-setf-able) Yes, setf'able are only (some) expressions (the "place expressions"), not plain values. If you evaluate a (place) expression (functions evaluate their arguments), you loose the connection to the place. That's why `setf', `cl-callf', `pop' e.a. are necessarily macros. (A suggesting analogy with quantum states that collapse when measured: places collapse to values when passed to a function.) > if car is an atom, but something still connected to the original list > structure (setf-able) if car is a cons cell? No, it's still not setf-able (try to replace the cons with an integer, for example). It's only that the original list and this cons share data (like so often in Lisp), so if you setf the car of this cons, the content of the original list is also altered. If the car of this cons was a string, and you use a destructive string operation on it, the original list also "changes" (in this sense). Nothing special about setf here. > If that's the case, I'm not sure how to reliably pass a settable value > in to `deep-edit'. We could pass gv-refs into `deep-edit', That would also be my first naive idea. > In which case it would have to check values to see if they're already > references or not (or gv-ref itself could do that check). It's easy to change the function to accept gv-refs instead of values, since it already uses them internally. But AFAIK there is no test if some value is a `gv-ref'. Do you need deep-edit to also accept plain values? Then you could just pass values V as (list :value V) to make the cases distinguishable. Regards, Michael.