[Top][All Lists]

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

Re: Enhancement to the syntax system?

From: Ludovic Courtès
Subject: Re: Enhancement to the syntax system?
Date: Mon, 09 Jul 2012 17:52:55 +0200
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux)


Stefan Israelsson Tampe <address@hidden> skribis:

> You do not need gensyms if you try to mimic or implement my suggested #. .
> On the
> other hand when if you do this
> (define (f stx) #`(let ((x 1)) #,stx))
> and use this with
> #`(let ((x 2)) #,(f #'x))

OK, got it, thanks!

(In case others wonder, the complete example is:

  (define (f stx)
    #`(let ((x 1)) #,stx))
  (define-syntax foo
    (lambda (s)
      (syntax-case s ()
         #`(let ((x 2)) #,(f #'x))))))

  => 1

The situation can be diagnosed with:

  (define (f stx)
    #`(let ((x 1))
      #,(if (bound-identifier=? stx #'x) (error) stx)))

But it doesn’t help.

> (with-syntax ((x (datum->syntax stx (gensym "x")))) #`(let ((x 2)) #,(f
> #'x))))))

Often, you could use ‘generate-temporaries’, which is a bit nicer.

> Hope that this makes things clear!

It does, thanks!

It’s true that it’s annoying that the wrong binding is silently used.
Do you think it’s common enough to justify new syntax?


reply via email to

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