guile-devel
[Top][All Lists]
Advanced

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

Re: Enhancement to the syntax system?


From: Stefan Israelsson Tampe
Subject: Re: Enhancement to the syntax system?
Date: Mon, 9 Jul 2012 19:40:33 +0200



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

Yes this highlights a comon problem when implementing racket match with #`. I do think
that the best solution is to somehow extend the syntax expander to mimic my sugested
#. and address@hidden The simple solution is to rewrite according to

#`(... #.((x y) (f #'x #'y)))

->

#`(let-syntax ((g (lambda (x) (syntax-case x () ((_ x y) (f #'x #'y))))))
      (... (g x y))

But before going this path it would be interesting to hear what the true wizards of
scheme have to say about this. It might have been considered already and good
advice could be taken from them. I also feel that the issue needs to be liffted up to the
community of at least syntax-case user crowd before doing anything Ill try to spur
some discussions on it and come back later!

/Stefan

On Mon, Jul 9, 2012 at 5:52 PM, Ludovic Courtès <address@hidden> wrote:
Hi!

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

  (foo)
  => 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?

Thanks,
Ludo’.




reply via email to

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