GNU bug report logs - #32847
Wrong macro expansion in eval

Previous Next

Package: guile;

Reported by: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>

Date: Wed, 26 Sep 2018 20:04:02 UTC

Severity: normal

Tags: notabug

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32847 in the body.
You can then email your comments to 32847 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#32847; Package guile. (Wed, 26 Sep 2018 20:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Wed, 26 Sep 2018 20:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: Wrong macro expansion in eval
Date: Wed, 26 Sep 2018 22:02:51 +0200
[Message part 1 (text/plain, inline)]
This for guile 2.4 and master,

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

;;; (#<syntax a> 1)


But without eval:
> (let-syntax ((f (lambda (x) #'(+ (pk 'a 1) 2)))) f)

;;; (a 1)
[Message part 2 (text/html, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#32847; Package guile. (Thu, 27 Sep 2018 02:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 32847 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>
Cc: 32847 <at> debbugs.gnu.org
Subject: Re: bug#32847: Wrong macro expansion in eval
Date: Wed, 26 Sep 2018 22:16:06 -0400
Hi Stefan,

Stefan Israelsson Tampe <stefan.itampe <at> 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




Information forwarded to bug-guile <at> gnu.org:
bug#32847; Package guile. (Thu, 27 Sep 2018 08:34:01 GMT) Full text and rfc822 format available.

Message #11 received at 32847 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 32847 <at> debbugs.gnu.org
Subject: Re: bug#32847: Wrong macro expansion in eval
Date: Thu, 27 Sep 2018 10:33:00 +0200
[Message part 1 (text/plain, inline)]
yes that makes sense. thanks!

On Thu, Sep 27, 2018 at 4:16 AM Mark H Weaver <mhw <at> netris.org> wrote:

> Hi Stefan,
>
> Stefan Israelsson Tampe <stefan.itampe <at> 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
>
[Message part 2 (text/html, inline)]

Added tag(s) notabug. Request was from Mark H Weaver <mhw <at> netris.org> to control <at> debbugs.gnu.org. (Thu, 27 Sep 2018 09:05:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 32847 <at> debbugs.gnu.org and Stefan Israelsson Tampe <stefan.itampe <at> gmail.com> Request was from Mark H Weaver <mhw <at> netris.org> to control <at> debbugs.gnu.org. (Thu, 27 Sep 2018 09:05:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Oct 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.