From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: What's the equivalent of `boundp' for lexical variables? Date: Sat, 27 Jan 2024 07:21:05 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dIjsPqtHgilM3U40" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15782"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 27 07:22:05 2024 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 1rTc4r-0003xD-Mv for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Jan 2024 07:22:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTc42-0001vN-BB; Sat, 27 Jan 2024 01:21:14 -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 1rTc40-0001vE-TD for emacs-devel@gnu.org; Sat, 27 Jan 2024 01:21:12 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTc3y-00067C-5s for emacs-devel@gnu.org; Sat, 27 Jan 2024 01:21:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BXtC6hxNlDMk8B6JL2K8xQVFE+cj2enMcyeaHYKPLVU=; b=WCz9TttpXomfgMcNT9nNJR7bma mHK3562Nkc0E2H9mJfkSUkZNGPeqZUrv+VMLbykZbvXRLRyaTEosirbhmIFvXA9DTVlTWuc4/zWp+ EEx0lqMOaQ5WHGgPB/Pokxf5yZVrKcGBJbW8Y7TNRlsp/9eNKysd26wSG9gt4DQh82RJYEmbx6iq2 wAca7Xw67dvSHqbNb3lLS5stpOGntdL5zhd1RPy8PdaIM88X9/njWnGlijMtSDvjt0DGwuteLmxuF iDShP73/Ek6NrfHVuW2F9zAryz9dxGgq3yY9mFED9b6UQtghRd/bBSi1i3qP6o2hQ+ZkPiDuNUmRU v5JjG7Zw==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1rTc3t-0000Ou-PX for emacs-devel@gnu.org; Sat, 27 Jan 2024 07:21:05 +0100 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:315464 Archived-At: --dIjsPqtHgilM3U40 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 26, 2024 at 08:16:46PM +0000, Alan Mackenzie wrote: > Hello, Emacs. >=20 > I have a problem in a macro, where I have the expression ,expr. I want > to evaluate it, but get the error message void-variable (expr). >=20 > In the good old days, I could have tested this with >=20 > (if (boundp 'expr) (eval ,expr)) >=20 > , but now, with lexical variables, I can't find the equivalent to boundp. > Is there such a facility for lexical variables, and if so what is it? To offer something which might be half-right, but less whimsical than the typical Andreas's answers: lexical variables are only "known" at compile time (something to bear in mind when building your macro; I take you know that). But functions, like "boundp" take a symbol at run time and query it. The whole compile-time "world" is now somewhere under the Atlantic Ocean and only legends talk about it :-) One work-around would be "ignore-errors" (I take this is roughly what Common Lispers do). Assume lexical bindings, assume foo hasn't been defined: (ignore-errors foo) =3D> nil (let ((foo 12)) (ignore-errors foo)) =3D> 12 (Ignore-errors is a macro, so it gets expanded when useful to you) Perhaps there's a solution along these lines. Cheers, hth --=20 tom=C3=A1s --dIjsPqtHgilM3U40 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZbSgyAAKCRAFyCz1etHa RofpAJ9YOF3pHg9p4Qdks2yXkWpQPYIYkQCfZL91JjCNIajHrHVAXZA/trkXmqc= =Z3oB -----END PGP SIGNATURE----- --dIjsPqtHgilM3U40--