From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Using the content of a dynamic variable in a macro Date: Sat, 25 Feb 2023 11:38:01 +0200 Message-ID: <83fsaukruu.fsf@gnu.org> References: <87o7pi9m9s.fsf@cassou.me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24184"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Damien Cassou Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 25 10:38:57 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pVr17-00064G-1Y for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Feb 2023 10:38:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVr0D-0000wM-Rk; Sat, 25 Feb 2023 04:38:01 -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 1pVr0C-0000wD-Dn for emacs-devel@gnu.org; Sat, 25 Feb 2023 04:38:00 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVr0B-00049C-NU; Sat, 25 Feb 2023 04:37:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=DnE3cqImu80BuntdByboJMVinFYpbJ5Sjzye579vA0w=; b=HJInSSnMWbUqXTelNc/w 0O38P/7scsup2H2IRc0aJf/tyHOyOd4PlAF0SL5221sSL99DGHT4o7vqf8dMRwZEFNY5k4IoIq/Tx jDkPsR4OB/aNFKmdTHgG1UgI/7n+FDHrQfeIteUQPrQxNx8d/rtny8Y8W9VwuiOcKBUd+GxySAb/l n/ujbPhFmZ10Ge1s6El3k8Zih+ffdxlsUUKLsAsMrOGgxG9Q9DqziFvGEDvP7tmpiaN3LEdg1fncE B9GFaI+R0TvZlY2/xEbU6+7C+s7i7BmpdXb1n62gBMsMj55+wXAiYniwOXFzSnoQQ4RMMP/CPeUNb XejG5J0XfaRPbA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVr0B-0008Tz-6z; Sat, 25 Feb 2023 04:37:59 -0500 In-Reply-To: <87o7pi9m9s.fsf@cassou.me> (message from Damien Cassou on Sat, 25 Feb 2023 09:34:07 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303786 Archived-At: > From: Damien Cassou > Date: Sat, 25 Feb 2023 09:34:07 +0100 > > I'm wondering why the code below works but won't compile. > > foo.el: > (defvar foo-var '((message "hello world"))) > > (defmacro foo-macro () > `(progn > ,@foo-var)) > > (defun foo-fun () > (foo-macro)) > > > $ emacs --batch -l foo.el --eval '(foo-fun)' > hello world > > $ emacs --batch --eval '(find-file "foo.el")' --eval '(emacs-lisp-byte-compile)' > In toplevel form: > foo.el:32:1: Error: Symbol’s value as variable is void: foo-var > > Why isn't the compiler aware of the foo-var variable? Because lexical-binding is turned on?