From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Using the content of a dynamic variable in a macro Date: Sun, 26 Feb 2023 12:47:57 +0100 Message-ID: <87sfesbqc2.fsf@web.de> References: <871qmftvzs.fsf@cassou.me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18703"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: help-gnu-emacs@gnu.org To: Damien Cassou Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 26 12:48:23 2023 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 1pWFVv-0004fY-HO for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 26 Feb 2023 12:48:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWFVc-0006x5-IX; Sun, 26 Feb 2023 06:48:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWFVZ-0006wu-BG for help-gnu-emacs@gnu.org; Sun, 26 Feb 2023 06:48:01 -0500 Original-Received: from mout.web.de ([212.227.15.4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWFVX-0008Jr-Ko for help-gnu-emacs@gnu.org; Sun, 26 Feb 2023 06:48:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1677412078; i=michael_heerdegen@web.de; bh=+85te+3mn4JAlWouYTbluxx1xp9Q+raJu6XS/sECpW8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=qT4zvhMRjZ0NRkPTh1kOMeyTQPr3gp/jUjHTs3mXL4kdXiYqBxB3jibwITREw8YwB vtkvkAtXvBhF2TBCc12LigFN5PGnmMWI2rDXuOmcf0kUhr7Cm7wzzPxYkF5tCcHDzg 9EQ+uVqNDxu8gJzl0cjLb1E2MG4vt2S4ofI3+85pIs5326zPPics5mknXS4o7pqdbU tPg4q7dZh4JmIZlOS8TCYfnaSNVbWHPQkNYfiWnpiOe0KcWxAKjz/HBr9FwkEcIli7 Y+A7k4jQRXMm+FBszXQfbId5VAIIUBA3M6BYzb3GpDbA5yeU6fhoJE3Oibfl0hymI5 IlItUL5pm3LfQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([84.59.210.57]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MF2gW-1pGuUX40UK-00FT8O; Sun, 26 Feb 2023 12:47:58 +0100 In-Reply-To: <871qmftvzs.fsf@cassou.me> (Damien Cassou's message of "Fri, 24 Feb 2023 07:31:35 +0100") X-Provags-ID: V03:K1:aTprmttz3ThP1JDuCDy3BU0qo5HiDwLwlaAQPZmw4FcqS6aVh12 OVE9vOnv9iCtPJLUCI79iaJO8RTfXFf6J6rqdIpYw1Sg5u4y0inDi3jGOlyEev52n0qDroI XPmmrOmo6svrTDZpMx2uYtKxrz6bQOgXHSp35jE/ZH/hl0yY90+nLI5sAwDf2xV4QJK9+U5 6vtADEPN0FBo3bzRVgH6w== UI-OutboundReport: notjunk:1;M01:P0:6BGHF8vr7p8=;ZPIi1GRa76aVh2YjCvxsNLyKtMG +g7Q+g6jVAogSd1ePGxcxbjSa6+ogWSIJaYlbu20aPN+8V01q8x+N++2Zx2SlpDenG7sCPIKg I99H7HmkHxk9W9Kyd6Boygrk4mrtygbm1Zdww/Fq9TX0U0SNkZKctBNRjs+6ULXrwECVZH6hc 4bzI8OyFKW/6jz1CBY9cJmPCDnSPiN9o9tboHJksV5ta6bv06Bp/T+ZZ0ZU1F0GUcV1gnYCMz Km3dXn9gSzzapLcMRTdxWd2mzLmKjmCoDgdNUs1sENW3isoXznZPH1BZ+qfX+RH500fDgIgwg zi2I6VLo39Dh45qpWZgEUXPSDBUrVvMdHfUH63b0kY3hudzmfZw7rw3pzfvKIcUYcnhCvY9Ar rVyAtoTh0200bwa8ek22SDNTwSlbg+i8OzBlHTDz31zyXdoIX/PybvE0I9iW/gV8hNIPC0GpD 7q989TnytSCvk2rpGnWZT+nfYYIJJZKrKwL7GQxz2kke+wGik5SoHUOlfZbZz1vRDFis2KjW4 byMvB+Fn4uLaU62zxcVUd0zf/70Wi1D/lxylirZsEohrlL+/wi+b82SBz6Kl4V0i7UM5RSyYh sHVWmFDaLGy//EzkmDA6774LkJwBBJ2/S4amZG+z68OefEnWz2iufj9m4BLPZq7WEFVFzd+nC bUsY5vE4HrScljW8tZ0XxRR4zxDm5e5K7pAKRKeTKEvi0a0fwjAy0Uwvnk+9FGX5OXmoJI5E4 D37wJe5gPUl/OFJ4LgWKyUW4f/xsM5Ko4sZZp86lDSE7W++FKENFJLWKFZovnluLqUJF2F1a Received-SPF: pass client-ip=212.227.15.4; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142847 Archived-At: Damien Cassou writes: > I'm wondering why the code below works but won't compile. > > foo.el: > (defvar foo-var '((message "hello world"))) >=20=20=20 > (defmacro foo-macro () > `(progn > ,@foo-var)) >=20=20=20 > (defun foo-fun () > (foo-macro)) > [...] > foo.el:32:1: Error: Symbol=E2=80=99s value as variable is void: foo-var > > Why isn't the compiler aware of the foo-var variable? The compiler is aware of it, but it doesn't eval the definition. It is a feature that the compiler normally does not load any part of the program when compiling, including variable definitions. Note that in the general case, evaluating a defvar form might require to load more parts of a file, or even the complete file. If you do need to eval something when compiling, use `eval-when-compile' or `eval-and-compile' respectively. Michael.