[racket] generate-temporaries with source location?

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Fri Jul 15 02:15:56 EDT 2011

On Fri, Jul 15, 2011 at 1:41 AM, Carl Eastlund <cce at ccs.neu.edu> wrote:
> It's easy to add this:
>
> (define (generate-temporaries/locs xs)
>  (for/list {[x (in-list (if (syntax? xs) (syntax->list xs) xs)]}
>    (define sym (if (identifier? x) (syntax-e x) 'fresh))
>    (define src (if (syntax? x) x #f))
>    (define mark (make-syntax-introducer))
>    (mark (datum->syntax #f sym src))))

Sweet!  Cool, I'll use that.  Thank you!


Just to show: here's the small toy I've been playing with, a syntax
for doing short-circuiting chains of boolean comparisons a-la Python:

    https://github.com/dyoo/chaining-compare


The chaining-compare macro provided by this is meant to cooperate with
the language where it is used.  So, for example, when it is being used
in:

    https://github.com/dyoo/chaining-compare/blob/master/small-test.rkt

the language used in small-test.rkt shows a debugging statement before
any procedure application.  But that means that any applications
constructed by the chaining-compare macro need to carefully use the
same kind of parens as the original syntax, because the macro will be
constructing its own applications.


I'm using datum->syntax in a controlled fashion to make sure the
applications that are being constructed in chaining-compare use the
same kind of parens as that of the originating program.  Dunno if this
is the best way to do what I'm doing, but it seems to be doing
something... :)



Posted on the users mailing list.