From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Douglas Lewan Newsgroups: gmane.emacs.help Subject: Re: Compiling a recursive macro Date: Thu, 11 Jun 2020 17:23:27 -0400 Message-ID: References: <22b55d6d-f719-98d9-f8c8-e72e7fc43497@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="114817"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 To: Stefan Monnier , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 11 23:24:51 2020 Return-path: Envelope-to: geh-help-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 1jjUgs-000Tmq-DQ for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Jun 2020 23:24:50 +0200 Original-Received: from localhost ([::1]:45924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUgr-0001gZ-9q for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Jun 2020 17:24:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjUgD-0001bV-SW for help-gnu-emacs@gnu.org; Thu, 11 Jun 2020 17:24:09 -0400 Original-Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:33436) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjUgB-00063S-MG for help-gnu-emacs@gnu.org; Thu, 11 Jun 2020 17:24:08 -0400 Original-Received: by mail-qv1-xf34.google.com with SMTP id d12so592230qvn.0 for ; Thu, 11 Jun 2020 14:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=dyJ/m7mYMDHYdxnwj0oLd1ojxprkGCMa5j/5fvXACiw=; b=DUWSFiQErn+ge5Tg99gSXP/CxCh+C2ioidCnEv1wUavOhrxqRHmTXXyYFE4MoWnzFO t5dzfmDi1X58gEdnO4lb0SaCsRq+T5jrN/3zWjcwkDX7n8QCgQZXbbwgDTh/8+PaoCkK 6eBBW1H6bv5zYAbtm9E4Gw7nE/aLXyCVN3BdgjVcXnOnTZwMeDm96cD6bnIBaExNysO3 LSgjfGGHaoWi91kGDEkrN05D3f01v1XpJ+NsKvInFWjrxMqev61I6GBw6IHMP9AfmZxY HxP7jubM6L6Q/94Sec3w/MOQvJYw8MgUOegV6F7SX9owyvpZwouqS6OZbQ1Vi7R0D6WI Og4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=dyJ/m7mYMDHYdxnwj0oLd1ojxprkGCMa5j/5fvXACiw=; b=jNL3Fk/hOGvSMI6Er7rsW38DXZbZ3F/J0dwq9SLMTwIj5/4K7NNi0V1xU13B1OjVcg GwCygY+5ipYNZ4VWDApyt9l+OcdJp5XWQosFvGmBV/8SdABl9Lqj6M7ZgaWeNoug21ml 2RSwRcqxidSI2lXArmEEC8HWewqBsc5Or557FH9XmcoXNQMCEGgEBKJ4VX1fK0dsqAYx xYniVUxX6ZEZt5HAWlTM+HJ/RMjMUpRN97Zi3bNYqtcWaiVe/AVWtrftFzWGY2EAtN/k RUff3k+dIkHIRArSw3TTNZx97je5aVXZH0lhZOOu3pTQD76l8y9lyDhksXHPrmhKcXa3 CTaQ== X-Gm-Message-State: AOAM532z+wGRD7jPa+gXG8JLMkLnSYpkg/grxM/i30Kkvm7SamBcsLQL JmJh/SPTq9DkSYqikPPwmOf8rxbbcA== X-Google-Smtp-Source: ABdhPJw54zj0QM8p/IoAk3DEvOMn/POcea2GcNx6sN4kebB2OIsdyXVXpmDN5E3iftfWhY1KHvfcng== X-Received: by 2002:ad4:4cce:: with SMTP id i14mr9590878qvz.233.1591910641226; Thu, 11 Jun 2020 14:24:01 -0700 (PDT) Original-Received: from [192.168.43.104] ([172.58.236.143]) by smtp.gmail.com with ESMTPSA id p185sm2863985qkd.128.2020.06.11.14.23.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2020 14:24:00 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=d.lewan2000@gmail.com; helo=mail-qv1-xf34.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:123336 Archived-At: On 6/11/20 4:57 PM, Stefan Monnier wrote: >> That suggests to me that you can't compile any recursive macro. > Depends what you mean by "recursive macro". > What this prevents is to use a macro inside the definition of a macro. > > Most cases of "recursive macros" instead just returns code which > itself uses that macro. In that case, there's no real recursion: the > macro just returns a list which happens to include a symbol which has > the same name as the macro. And then the macro-expander will end up > calling that macro back when it gets to macro-expanding that chunk > of code. > This works just fine (and may inf-loop, of course). It did work when not compiled. However, when compiling I got a max-depth-exceeded error. (Forgive the paraphrasing, I'm now running a new instance of emacs. And, if anyone cares, I did find a work-around for the macro in question. It had the following structure: (defmacro mmm () (cond ((at-root-p) do  tree-wide stuff) (t (with-current-buffer root (mmm))) Since there is never more than one level of recursion, I defined another macro to do the tree-wide stuff first and then call that from mmm. -- ,Doug d.lewan2000@gmail.com (908) 720 7908 If this is what winning looks like, I'd hate to see what losing is.