bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32847: Wrong macro expansion in eval


From: Stefan Israelsson Tampe
Subject: bug#32847: Wrong macro expansion in eval
Date: Thu, 27 Sep 2018 10:33:00 +0200

yes that makes sense. thanks!

On Thu, Sep 27, 2018 at 4:16 AM Mark H Weaver <address@hidden> wrote:
Hi Stefan,

Stefan Israelsson Tampe <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]