* (un)quoting, evaluation, and environments
@ 2020-08-31 20:31 Stephen Scheck
2020-08-31 20:59 ` Stephen Scheck
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Scheck @ 2020-08-31 20:31 UTC (permalink / raw)
To: guile-user
Hello,
I'm puzzled by what is going on here:
scheme@(guile-user)> (eval-string "`(foo ,b)")
ERROR: In procedure %resolve-variable:
Unbound variable: b
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (define b 'bar)
scheme@(guile-user)> (eval-string "`(foo ,b)")
$1 = (foo bar)
scheme@(guile-user)> (null-environment 5)
$2 = #<interface (#{ g298}#) 7f4447df16e0>
scheme@(guile-user)> (eval-string "`(foo ,b)" $2)
$3 = (foo (unquote b))
scheme@(guile-user)> (eval-string "`(foo ,b)" (current-module))
$4 = (foo bar)
scheme@(guile-user)> (module-ref (current-module) 'b)
$5 = bar
scheme@(guile-user)> (module-ref $2 'b)
ERROR: In procedure scm-error:
No variable named b in #<interface (#{ g298}#) 7f4447df16e0>
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (module-define! $2 'b 'bar)
scheme@(guile-user)> (module-ref $2 'b)
$6 = bar
scheme@(guile-user)> (eval-string "`(foo ,b)" $2)
$7 = (foo (unquote b))
Why does b get evaluated in the default environment (current module), but
gets unquoted for one passed as an argument to eval-string? What is
different about these environments? Is there a correct way to use a
different environment, such that the result is the same?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: (un)quoting, evaluation, and environments
2020-08-31 20:31 (un)quoting, evaluation, and environments Stephen Scheck
@ 2020-08-31 20:59 ` Stephen Scheck
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Scheck @ 2020-08-31 20:59 UTC (permalink / raw)
To: guile-user
> Why does b get evaluated in the default environment (current module), but
gets unquoted for one passed as an argument to eval-string? What is
different about these environments? Is there a correct way to use a
different environment, such that the result is the same?
Hmm ... if I call (make-fresh-user-module) instead of (null-environment 5),
it works ... *shrug* ... but is that the safest way to get an empty
environment for evaluation purposes?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-31 20:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 20:31 (un)quoting, evaluation, and environments Stephen Scheck
2020-08-31 20:59 ` Stephen Scheck
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).