unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#32847: Wrong macro expansion in eval
@ 2018-09-26 20:02 Stefan Israelsson Tampe
  2018-09-27  2:16 ` Mark H Weaver
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Israelsson Tampe @ 2018-09-26 20:02 UTC (permalink / raw)
  To: 32847

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

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)

[-- Attachment #2: Type: text/html, Size: 798 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#32847: Wrong macro expansion in eval
  2018-09-26 20:02 bug#32847: Wrong macro expansion in eval Stefan Israelsson Tampe
@ 2018-09-27  2:16 ` Mark H Weaver
  2018-09-27  8:33   ` Stefan Israelsson Tampe
  0 siblings, 1 reply; 3+ messages in thread
From: Mark H Weaver @ 2018-09-27  2:16 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: 32847

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#32847: Wrong macro expansion in eval
  2018-09-27  2:16 ` Mark H Weaver
@ 2018-09-27  8:33   ` Stefan Israelsson Tampe
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Israelsson Tampe @ 2018-09-27  8:33 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: 32847

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

yes that makes sense. thanks!

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

> 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
>

[-- Attachment #2: Type: text/html, Size: 1690 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-27  8:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 20:02 bug#32847: Wrong macro expansion in eval Stefan Israelsson Tampe
2018-09-27  2:16 ` Mark H Weaver
2018-09-27  8:33   ` Stefan Israelsson Tampe

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).