public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: Per Bothner <per@bothner.com>
Cc: kawa <kawa@sourceware.org>
Subject: Re: Evaluating definitions from another thread
Date: Fri, 10 May 2024 23:03:00 +0200	[thread overview]
Message-ID: <CAMFYt2Z2Wmu3_RDxgu8YrApgA-0NLSODmALLeXCA8oGjwJ0wdw@mail.gmail.com> (raw)
In-Reply-To: <9e584c45-8a18-458b-ba2b-0f27450490d7@bothner.com>

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

pt., 10 maj 2024 o 22:19 Per Bothner <per@bothner.com> napisał(a):

>
>
> On 5/10/24 1:15 PM, Panicz Maciej Godek via Kawa wrote:
> > Hi,
> >
> > I've noticed that when I call
> >
> > (future (eval '(define x 5)))
> >
> > then the variable x remains unbound after the execution
> > - even though when I invoke (eval '(define x 5)), x gets bound to 5 as
> > expected.
>
> This might work:
>
> (define x #f)
> (future (eval '(set! x 5)))
>


Thanks, it does the trick for simple cases.
I currently scan for the appearance of "define", then extract for the
symbol and build a binding, and then evaluate

`(set! ,symbol
   (let ()
    ,expression
    ,symbol))

but if I wanted to handle a more general case (such as a begin form
containing some definitions), I'd probably need to implement something
closer to a full evaluator,
which makes me wonder whether the above behavior (with variables not being
bound from other threads) is actually desired?

  reply	other threads:[~2024-05-10 21:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 20:15 Panicz Maciej Godek
2024-05-10 20:19 ` Per Bothner
2024-05-10 21:03   ` Panicz Maciej Godek [this message]
2024-05-11  0:49     ` Per Bothner
     [not found]       ` <CAMFYt2bqd3LNLPFgdhpaDrSkdM_SLGCGYnSqs0-gw0Z9n-OFqw@mail.gmail.com>
     [not found]         ` <4c435a3e-0517-46c5-b541-88f1355dfe4b@bothner.com>
2024-05-12 21:08           ` Panicz Maciej Godek
2024-05-12 21:22             ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMFYt2Z2Wmu3_RDxgu8YrApgA-0NLSODmALLeXCA8oGjwJ0wdw@mail.gmail.com \
    --to=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).