Evaluating definitions from another thread
Panicz Maciej Godek
godek.maciek@gmail.com
Fri May 10 21:03:00 GMT 2024
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?
More information about the Kawa
mailing list