From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: Help with recursive destructive function Date: Mon, 14 May 2018 09:57:34 -0700 Message-ID: <87bmdixji9.fsf@ericabrahamsen.net> 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1526317683 9265 195.159.176.226 (14 May 2018 17:08:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 14 May 2018 17:08:03 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 14 19:07:59 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 1fIGx3-0002FM-D5 for ged-emacs-devel@m.gmane.org; Mon, 14 May 2018 19:07:57 +0200 Original-Received: from localhost ([::1]:47337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGz8-0004d1-RJ for ged-emacs-devel@m.gmane.org; Mon, 14 May 2018 13:10:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGpv-0004FJ-JQ for emacs-devel@gnu.org; Mon, 14 May 2018 13:00:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIGpr-00017i-QM for emacs-devel@gnu.org; Mon, 14 May 2018 13:00:35 -0400 Original-Received: from [195.159.176.226] (port=56373 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIGpr-00016K-Io for emacs-devel@gnu.org; Mon, 14 May 2018 13:00:31 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fIGnf-0008Ic-RF for emacs-devel@gnu.org; Mon, 14 May 2018 18:58:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:gkJWxbPNJ2n62tCILtKEygmo1WI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:225292 Archived-At: Michael Heerdegen writes: > Eric Abrahamsen writes: > >> This is great, and I really like the use of gv -- morally it seems like >> the right tool. > > Didn't profile speed, however - hope it's good enough. I'm trying to break the changes into discrete steps, and benchmark each step, so hopefully we'll know. >> I will have time this weekend to apply all this to eieio-persistent. > > Where can I have a look at your work? Nowhere yet -- I got partway through this, and ran up against a dumb problem maybe you can help me with. For backwards compatibility, we need to be able to handle lists that are quoted, or that start with the symbol `list'. This will sound familiar to you... In the non-destructive version, it was easy enough just to return (cdr thing) instead of thing. In the destructive version, this means that `handle-refs' would need to first edit and *then* traverse the cons, which is not what it's set up to do, obviously. I could probably cheat and move the backward compatibility into some other part of `deep-edit' itself, but I was trying to avoid that because that function could be useful elsewhere as part of the general library. Here's what the problem actually looks like: #+BEGIN_SRC elisp (defun edit-func (proposed-value) (cond ((and (consp proposed-value) (eq (car proposed-value) 'list)) #'cdr) ((and (consp proposed-value) (eq (car proposed-value) 'quote)) #'cadr) ((stringp proposed-value) #'upcase) (t nil))) (let ((tree '("b" '((first ("one" "two" "three")) (second ("four" "five" "six"))) "c" (list "seven" "eight" "nine")))) (deep-edit #'edit-func (lambda (thing) (consp thing)) tree) tree) #+END_SRC Do you have any good ideas about this? Thanks again, Eric