From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.lisp.guile.user Subject: Re: Re: intern a top level variable Date: Wed, 16 Aug 2023 19:58:54 +0200 Message-ID: References: <5306923bbfa46630b22c6dc978e89b60d0565ad9.camel@abou-samra.fr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="llwhRv/WDfQ9yvmH" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8768"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mortimer Cladwell , guile-user@gnu.org To: Jean Abou Samra Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 16 19:59:33 2023 Return-path: Envelope-to: guile-user@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 1qWKns-0001yV-7b for guile-user@m.gmane-mx.org; Wed, 16 Aug 2023 19:59:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWKnP-000050-6K; Wed, 16 Aug 2023 13:59:03 -0400 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 1qWKnN-0008WO-73 for guile-user@gnu.org; Wed, 16 Aug 2023 13:59:01 -0400 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 1qWKnK-0000Oc-JU for guile-user@gnu.org; Wed, 16 Aug 2023 13:59:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject :Cc:To:From:Date:Sender:Reply-To: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=PXxo7W9Nvd7tlXhecy1Y+ttuziYJzexqwvhJkvSHBdY=; b=mvS1vh20ezwPDWuLVJCMf7oH7K B5avZ55Ct+d5R+t9rRkMhb2cVOJC78uS2XZNspMtW3NHMTJYGu8yMjyoNbFmSjv42FgCkczfAh0Xt L/owdeleDcnWMfCPqGaEfUK+BqjXxMnSJ+I1o/ILOC8cO22oNnCWlkyCXMEr0Z6CxfD9oqjOFXyoh r3UXFmHVRqwIMI9EHyDk4kLaYWLzr6RCcLfbu+WyP/e/M+ByAx+0nNKeub8XESwiooIf2EqVODbq5 A5fVUGMMA3IVxpiHYfXUX3YbCrI2QCNdn3aqi5HFyJliw9pF5jdP/Brm3oV79ymnwaWXd+PY9qrQs S9bPZ5Bg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qWKnG-0004tS-Uf; Wed, 16 Aug 2023 19:58:54 +0200 Content-Disposition: inline In-Reply-To: <5306923bbfa46630b22c6dc978e89b60d0565ad9.camel@abou-samra.fr> 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19168 Archived-At: --llwhRv/WDfQ9yvmH Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 16, 2023 at 06:13:05PM +0200, Jean Abou Samra wrote: > Le mercredi 16 ao=C3=BBt 2023 =C3=A0 10:55 -0400, Mortimer Cladwell a =C3= =A9crit=C2=A0: > > I would like to intern and assign a value within a method: > >=20 > > (define (test-intern) > > (let* ((name "abc") > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (data "def") > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (name-symbol (gensym name)) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ) > > =C2=A0 (pretty-print (string-append "symbol: " (symbol->string name-sym= bol))) > > =C2=A0 (set! name-symbol data))) > >=20 > > scheme@(guile-user)> (test-intern) > > "symbol: abc3301" > > scheme@(guile-user)> abc3301 > > ;;; : warning: possibly unbound variable `abc3301' > > ERROR: In procedure module-lookup: Unbound variable: abc3301 >=20 >=20 > Sorry, but it's not clear to me what you mean by "intern and assign a val= ue", > and I don't think it will be clear to someone else. >=20 > Can you be more precise please? I think what the OP wants is to make a binding for an existing symbol. Something, perhaps like scheme@(guile-user)> (define foovar (gensym "foo")) scheme@(guile-user)> foovar $1 =3D foo170 scheme@(guile-user)> (module-add! (current-module) foovar (make-variable = 42)) scheme@(guile-user)> foo170 $2 =3D 42 (note that the "top level" is Just Another Module). Mortimer: is that what you were looking for? Note that "you usually don't do this" (whatever that means), so it'd make sense to take a step back and think about what you are trying to achieve :-) > I don't understand why you expect "abc3301" to be bound after running (te= st- > intern). That (test-intern) call just creates a symbol, which is interned= as a > symbol, meaning that creating another (interned) symbol with the same nam= e will > reuse the same symbol value. But there is no reason why it shoud be bound= to a > variable. Symbol interning just applies to symbols as values, it has noth= ing to > do with variables. In any case it would make sense to revisit the concepts of "symbol", "variable" and "binding". It's subtle, but in Lispy lands it is indispensable. Cheers --=20 t --llwhRv/WDfQ9yvmH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZN0OVwAKCRAFyCz1etHa Rn95AJ9M4rJ6dl9b409YCxuLiT8s3OMngACfUF2d9Xq3gH/Fpqnm02PreQoFrKU= =a/Ra -----END PGP SIGNATURE----- --llwhRv/WDfQ9yvmH--