From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Jakub Jankiewicz Newsgroups: gmane.emacs.help Subject: Re: Compiling a recursive macro Date: Fri, 12 Jun 2020 02:03:14 +0200 Message-ID: <20200612020314.7477d837@jcubic> References: <22b55d6d-f719-98d9-f8c8-e72e7fc43497@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/ez.FFj+mSB5=abrxA3AsUiL"; protocol="application/pgp-signature"; micalg=pgp-sha256 Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="118964"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Douglas Lewan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 12 02:03:58 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 1jjXAs-000UpX-0Z for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 Jun 2020 02:03:58 +0200 Original-Received: from localhost ([::1]:59388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjXAr-0007bC-2t for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Jun 2020 20:03:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjXAP-0007b4-EK for help-gnu-emacs@gnu.org; Thu, 11 Jun 2020 20:03:29 -0400 Original-Received: from smtpo90.poczta.onet.pl ([213.180.149.143]:54274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjXAN-000661-Ji for help-gnu-emacs@gnu.org; Thu, 11 Jun 2020 20:03:29 -0400 Original-Received: from jcubic (unknown [185.129.114.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jcubic@onet.pl) by smtp.poczta.onet.pl (Onet) with ESMTPSA id 49jgsv696qz1XPhtS; Fri, 12 Jun 2020 02:03:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onet.pl; s=2011; t=1591920196; bh=tVAXtQ6m3h58FWbievuSqzy7eNtfeaxdQCWCNBLZy8Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Qh+r0rLOBryLXwcDpGOC2A1m5O5us7dXSNmHr76f5cJm1D8myu+NKXDUpNlLjvnao /rZh0PEmX6D2qVsuBgALuzmx08FK1evgF3mb6MaRBGWSUaRW7FOg1DrZeoNf/i3QNN ySij+ocWdIeci8P/WlLhWjanC2oiHHhAq6ZSgVp4= In-Reply-To: <22b55d6d-f719-98d9-f8c8-e72e7fc43497@gmail.com> X-Mailer: Claws Mail 3.17.3git196 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-ONET_PL-MDA-SEGREGATION: 0 Received-SPF: pass client-ip=213.180.149.143; envelope-from=jcubic@onet.pl; helo=smtpo90.poczta.onet.pl X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 20:03:21 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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:123350 Archived-At: --Sig_/ez.FFj+mSB5=abrxA3AsUiL Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 11 Jun 2020 16:15:05 -0400 Douglas Lewan wrote: > I'm not an expert on macros whatsoever. I apologize if this is idiotic. >=20 > I've been doing battle trying to define a recursive macro, and I'd like=20 > it to be byte compiled. However, in the info (elisp) Compiling Macros, I= =20 > find the following: >=20 > =C2=A0=C2=A0 In order for compilation of macro calls to work, the ma= cros must > already be defined in Lisp when the calls to them are compiled. >=20 > That suggests to me that you can't compile any recursive macro. Do I=20 > understand it correctly? If I do, then I'm curious if there's a common=20 > style for getting around this. Here is example of recursive macro: (defmacro case_ (val &rest list) "(case value (() result1) (() result2) [else result3]) Macro for switch case statement. It test if value is any of the item. If item match the value it will return coresponding result expression value. If no value match and there is else it will return that result." (if (listp list) (let* ((item (car list)) (first (car item)) (result (cadr item)) (rest (cdr list)) (value (gensym))) `(let ((,value ,val)) (if (member ,value ',first) ,result ,(if (and (listp rest) (eq (caar rest) 'else)) 'xxx (if (not (null rest)) `(case_ ,value ,@rest)))))) nil)) (case_ (+ 1 2) ((1 2) 'foo) ((4 3) 'bar)) it's converted from Scheme code for my LIPS interpteter. -- Jakub Jankiewicz, Web Developer https://jcubic.pl/me --Sig_/ez.FFj+mSB5=abrxA3AsUiL Content-Type: application/pgp-signature Content-Description: Podpis cyfrowy OpenPGP -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEvGU/kjFLOYteHgvHpY7m8TH4MBMFAl7ixkIACgkQpY7m8TH4 MBM8PQgAwqY2iBEqWMk5SKKhta2riUa7IG5eqOAuxXq2EhQCuVDaSsGrmrrskGm3 6mLqY+0p1H0KUKxMkltRaTDmKFyiKgaGjH6+2tTiT5gZHjnQnYnw5+ddJIQHQWCO ApDYlT0J8zmtk27pg/XB14vES2hgJYl+eGnFEQEfCWNWCXN0Iq6eRfemSdSN0gHe K1r8iFKElMvlUbtqiFuqXe9oDRekzTOtoJj7Mpboka1zQ3K6pNrdOeuMxgdsYzDK ln6i9FSSCXH2feMfuKZByBhLcKCUAmm5XYnuFW9ZabgRlmi7ixaW2JKlJFSj6/WU toKcjnkuT9xG4b87eh6JewYHJeFBTw== =qCjc -----END PGP SIGNATURE----- --Sig_/ez.FFj+mSB5=abrxA3AsUiL--