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: Thu, 07 Jun 2018 09:51:09 -0700 Message-ID: <87y3fqsfpe.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> <87vaayp4p8.fsf@ericabrahamsen.net> <87in6yw06e.fsf@web.de> <87wovbvd6y.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1528390197 16640 195.159.176.226 (7 Jun 2018 16:49:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 7 Jun 2018 16:49:57 +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 Thu Jun 07 18:49:53 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 1fQy6i-0004DQ-RB for ged-emacs-devel@m.gmane.org; Thu, 07 Jun 2018 18:49:52 +0200 Original-Received: from localhost ([::1]:59210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQy8q-0002CN-19 for ged-emacs-devel@m.gmane.org; Thu, 07 Jun 2018 12:52:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQy8G-0002C6-6I for emacs-devel@gnu.org; Thu, 07 Jun 2018 12:51:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQy8C-0001KB-3q for emacs-devel@gnu.org; Thu, 07 Jun 2018 12:51:28 -0400 Original-Received: from [195.159.176.226] (port=50318 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQy8B-0001Jc-S6 for emacs-devel@gnu.org; Thu, 07 Jun 2018 12:51:24 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fQy5w-0003P7-4B for emacs-devel@gnu.org; Thu, 07 Jun 2018 18:49:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:IxMB/36kMcwBZIuCZ/+h0/Ey2qU= 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:226092 Archived-At: Stefan Monnier writes: >> I think this function could be useful in many situations, so I'd like to >> make it fairly general -- gv-refs or values. > > Why "or values"? It's easy for the caller to wrap its argument in > `(gv-ref ...)` and lets the function be more efficient. Fair enough, I guess I was just thinking gv-ref will be unfamiliar to most people, but if the docstring is clear it doesn't matter. >> How would you feel about gv-ref itself doing a check? >> >> (if (and (eq 'closure (caar place)) >> (eq 'closure (cadr place))) >> place >> (gv-letplace ...etc...) >> >> Too hacky? > > Beside the obvious problem of checking equality vs `closure` which will > break down with byte-compiled code, the more serious problem is that > this code is run at macro-expansion time, not at run-time, so `place` is > a Elisp *expression* and not an Elisp *value*. > > IOW your test will only trigger when the *source code* is of the form > > (gv-ref ((closure ...) . (closure ...))) Bleagh, okay. I will stop trying to be clever. Thanks, Eric