unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Cc: 32847@debbugs.gnu.org
Subject: bug#32847: Wrong macro expansion in eval
Date: Wed, 26 Sep 2018 22:16:06 -0400	[thread overview]
Message-ID: <875zyrelcp.fsf@netris.org> (raw)
In-Reply-To: <CAGua6m1uONhx_+U0y=hue4UEtdwRtaEx=Bhp94AGq6kDbdOrAA@mail.gmail.com> (Stefan Israelsson Tampe's message of "Wed, 26 Sep 2018 22:02:51 +0200")

Hi Stefan,

Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> This for guile 2.4 and master,
>
>> (eval `(let-syntax ((f (lambda (x) ,#'(+ (pk 'a 1) 2)))) f) (current-module)) 
>
> ;;; (#<syntax a> 1)
>
> But without eval:
>> (let-syntax ((f (lambda (x) #'(+ (pk 'a 1) 2)))) f)  
>
> ;;; (a 1)

I think the mistake is in your code above.  In the first case, what you
want is this:

  (eval `(let-syntax ((f (lambda (x) ,'#'(+ (pk 'a 1) 2)))) f)
        (current-module))

Note the addition of a quote (') between the unquote (,) and syntax (#')
above.

The expression that follows unquote (,) should evaluate to an
s-expression.  In this case, you want it to evaluate to the s-expression
#'(+ (pk 'a 1) 2), i.e. (syntax (+ (pk 'a 1) 2)), i.e. a list with two
elements, the first being the symbol 'syntax'.  But that's not what
you're doing above.  Instead, you are returning the syntax object
itself, which is being spliced directly into the code.

Does that make sense?

       Mark





  reply	other threads:[~2018-09-27  2:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 20:02 bug#32847: Wrong macro expansion in eval Stefan Israelsson Tampe
2018-09-27  2:16 ` Mark H Weaver [this message]
2018-09-27  8:33   ` Stefan Israelsson Tampe

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=875zyrelcp.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=32847@debbugs.gnu.org \
    --cc=stefan.itampe@gmail.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).