From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mortimer Cladwell Newsgroups: gmane.lisp.guile.user Subject: Re: Re: intern a top level variable Date: Wed, 16 Aug 2023 15:17:06 -0400 Message-ID: References: <5306923bbfa46630b22c6dc978e89b60d0565ad9.camel@abou-samra.fr> 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="28038"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org, tomas@tuxteam.de To: Jean Abou Samra Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 16 21:17:50 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 1qWM1b-0006xL-J9 for guile-user@m.gmane-mx.org; Wed, 16 Aug 2023 21:17:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWM1D-0001Dm-P1; Wed, 16 Aug 2023 15:17:23 -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 1qWM1B-0001DI-TH for guile-user@gnu.org; Wed, 16 Aug 2023 15:17:21 -0400 Original-Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWM19-0000gM-JG for guile-user@gnu.org; Wed, 16 Aug 2023 15:17:21 -0400 Original-Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-686bc261111so4941431b3a.3 for ; Wed, 16 Aug 2023 12:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692213438; x=1692818238; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mN19JOEvLxs/TtkM6roSpsaeaeHrfR/6rP3Sr39PFhY=; b=lGQ4PtFbiSz0DWL8eIeXhsizlPZ+z+CfoMh7oMV/NBncRuqYjWUavBOd15fRwryqSS KlsngWroqf3jkfYZ3G8DOW3P3tLoV/DWbte3b0Vg2fyTqev2spjsUPdeRxTFPoOveGpX 7zEZoWxaal8N97kmoRbl08Zivyn93E/tPkC4V/vzTBUBTZAKbU8/rxsUWrVFN/L5RxPD JGQHsYQhYjfiLT8BLkvfr4Ohs6IolKVzq5Fsq/gimYH081KCLhMoZhwOtiuIyYgRrgcL NBnP8FjQtmkt7ZpGmTtMaqucFYr6pDkcG1wNnR/xw79jtFw5mhsAaXszn9gt/PzFlhOh sz7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692213438; x=1692818238; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mN19JOEvLxs/TtkM6roSpsaeaeHrfR/6rP3Sr39PFhY=; b=eNstt3xEgLWK5HlyukPFg34FZngktbYWTeLI/p5VZaGdRr/XxIOduBW8F4O6TLu8CP EF8HVB1sUUNU2eNEhtOAlEIIycw63TmWIPIMP/iwICdSBN3TPFAJzYLBLripvXLEw9IL 8IoVNyfUaWwfZzmWUT3TQJHTo3wfuXWFU1KfSY2ctaxoFhAOZmSroksao2+HxD6vJCao GPk/g8jVt8mQR4GKJzRNKYMt5sRGmi5W4tDOgaQ1lTq7bZVpGD2gUe64FL8k1oKwe2D6 1g7YMkj+nAyo0DRwrGGGhUo2R6aT0mumWB8Jg2fxRUZ7lCmRCgk+jT0LXG2MU289jelw uSIw== X-Gm-Message-State: AOJu0YyQVdDe/burNIbuAmSjIVn9regTvQXWXdIClJ+IbdGsILmo36Te 1MRmX3+SWXX4i+Fs183UZEOPdUbs6zWx17JmuXJWOW+Rrc8= X-Google-Smtp-Source: AGHT+IE5yWmmBBvY3zVn0uRHYMso8hg3HHEZTaSHRTnk4f+rS8vwKhelEVgwgiLoxm5O9U8hozC4YSp60jXAlON1d4c= X-Received: by 2002:a05:6a00:390f:b0:687:3d65:7792 with SMTP id fh15-20020a056a00390f00b006873d657792mr2887048pfb.20.1692213438055; Wed, 16 Aug 2023 12:17:18 -0700 (PDT) In-Reply-To: <5306923bbfa46630b22c6dc978e89b60d0565ad9.camel@abou-samra.fr> Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=mbcladwell@gmail.com; helo=mail-pf1-x429.google.com 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:19169 Archived-At: I would like to define a variable within a method but make it available to the entire module - globally. Take a string "abc" convert to a variable (symbol??) abc and set to the string value "def". The values of name and data are unknown - they are variable. In this example the variable (symbol??) abc should evaluate to "def". Thanks tomas you set me on the correct path. The following works: (define (test-intern) (let* ((name "abc") (data "def") ) (module-define! (current-module) (string->symbol name) data)) ) scheme@(guile-user)> (test-intern) scheme@(guile-user)> abc $14 =3D "def" So yes I will need to read more about interning. Thanks Mortimer On Wed, Aug 16, 2023 at 12:13=E2=80=AFPM Jean Abou Samra wrote: > Le mercredi 16 ao=C3=BBt 2023 =C3=A0 10:55 -0400, Mortimer Cladwell a =C3= =A9crit : > > I would like to intern and assign a value within a method: > > (define (test-intern) > (let* ((name "abc") > (data "def") > (name-symbol (gensym name)) > ) > (pretty-print (string-append "symbol: " (symbol->string name-symbol))) > (set! name-symbol data))) > > scheme@(guile-user)> (test-intern) > "symbol: abc3301" > scheme@(guile-user)> abc3301 > ;;; : warning: possibly unbound variable `abc3301' > ERROR: In procedure module-lookup: Unbound variable: abc3301 > > > > Sorry, but it's not clear to me what you mean by "intern and assign a > value", and I don't think it will be clear to someone else. > > Can you be more precise please? > > I don't understand why you expect "abc3301" to be bound after running > (test-intern). That (test-intern) call just creates a symbol, which is > interned as a symbol, meaning that creating another (interned) symbol wit= h > the same name will reuse the same symbol value. But there is no reason wh= y > it shoud be bound to a variable. Symbol interning just applies to symbols > as values, it has nothing to do with variables. > > >