scsh-users
[Top] [All Lists]

Re: Dirty macros with define-syntax? Re: An Advanced Syntax-Rules Primer

To: scsh-news@zurich.ai.mit.edu
Subject: Re: Dirty macros with define-syntax? Re: An Advanced Syntax-Rules Primer for the Mildly Insane
From: rthappe@web.de (RT Happe)
Date: 5 Mar 2002 11:13:18 -0800
Organization: http://groups.google.com/
Michael Sperber [Mr.  Preprocessor] writes:
> >>>>> "Brian" == Brian D Carlstrom <bdc@zurich.ai.mit.edu> writes:

> Brian> define-syntax does not have to be used with syntax-rules. You can
> Brian> provide a functon to do explicit s-exp based conversion.

> Brian> I tried to find a simple example but...
> 
> There's documumentation at
> 
> ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/prop/exrename.ps.gz
> 
> which applies to Scheme 48/scsh as well, with the exception of the
> TRANSFORMER keywords, which is omitted here.

There are three simple examples in scsh-0.6.1/scheme/misc/doodl.scm
(the macros SETTER, DEFINE-SETTER, and BIND).  Basically, you rename
rather than gensym, and compare names with the dedicated comparison
function rather than with Scheme's EQ? or something.

  (define-syntax foo
    ;; transforms EXP --> EXP'
    (lambda (exp rename eq?) ...))

[ What I called names may be symbols but also ``generated names'' 
depending on the context of the macro call (FOO X ...).  If you
do not compare names in the way you should  your macro FOO may 
break when called from within the (intermediate) expansion
of another macro call like (BAR X) with

  (define-syntax bar
    (syntax-rules () ((bar ?x ...) (* * * (foo ?x ...) * * *))))
]

rthappe

<Prev in Thread] Current Thread [Next in Thread>