[racket] syntax-temporaries srfi-53

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Fri Sep 27 09:17:53 EDT 2013

Be careful using gensym to create unique variables.  If you compile a
program that uses a gensym'd variable, you can run into problems arising
from odd interactions between uninterned symbols and the
marshalling/unmarshalling process for bytecode files.  It's always safe to
use generate-temporaries (or generate-temporary from racket/syntax for just
one identifier), even in compiled programs.

Carl Eastlund


On Fri, Sep 27, 2013 at 1:23 AM, Niitsuma Hirotaka <
hirotaka.niitsuma at gmail.com> wrote:

> Also I found
>
> (define-macro (syntax-gensym k)
>   (let ((var (gensym)))
>     `(syntax-return
>       ,k
>       ,var)
> ))
>
> can generate  unique variable.
>
> Usage
>
> (define-syntax-computation testing
>   (computation-rules (  )
>     (( _  v )
>      (syntax-do
>       (var <- (syntax-gensym))
>       (syntax-return var)
>     ))))
>
> 2013/9/26 Asumu Takikawa <asumu at ccs.neu.edu>:
> > On 2013-09-26 12:54:45 +0900, Niitsuma Hirotaka wrote:
> >> How to use unique name variable within srfi-53 ?
> >
> > I'm not sure why that PLaneT package has that behavior, but if you just
> > want to generate new identifiers, you can use the built-in
> > `generate-temporaries` function:
> >
> >   Welcome to Racket v5.90.0.9.
> >   -> (generate-temporaries '(x y z))
> >   '(#<syntax x4> #<syntax y5> #<syntax z6>)
> >
> > Cheers,
> > Asumu
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130927/30b77a46/attachment-0001.html>

Posted on the users mailing list.