unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Stephen Scheck <singularsyntax@gmail.com>
To: guile-user@gnu.org
Subject: (un)quoting, evaluation, and environments
Date: Mon, 31 Aug 2020 16:31:46 -0400	[thread overview]
Message-ID: <CAKjnHz0DucSH00E+nW+BJJjXtE+RZ-e5E8WyrKOtiJOutRkfog@mail.gmail.com> (raw)

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?


             reply	other threads:[~2020-08-31 20:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 20:31 Stephen Scheck [this message]
2020-08-31 20:59 ` (un)quoting, evaluation, and environments Stephen Scheck

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=CAKjnHz0DucSH00E+nW+BJJjXtE+RZ-e5E8WyrKOtiJOutRkfog@mail.gmail.com \
    --to=singularsyntax@gmail.com \
    --cc=guile-user@gnu.org \
    /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).