chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Explicit Renaming Macros Help/Tutorial?


From: Jack Trades
Subject: [Chicken-users] Explicit Renaming Macros Help/Tutorial?
Date: Sun, 7 Jun 2009 18:40:59 -0400

I'm revisiting a problem I had a few months ago when developing a DSL and it was suggested that explicit renaming macros would be the easiest solution.  However after reading everything macro-related I could find on the web I'm still nowhere.  If someone could point me to a tutorial for the thick-headed I would be greatly appreciative.

I've found tons of info on syntax-rules, but I don't think I can do this without segment matching.  I have a number of similar transformations to make and if I could understand just one I think I could figure out the rest.

I'm trying to transform...

(def (name arg ... (optional-arg value) ... *rest) body ...)

Where there can be any number of args and any number of (optional-arg value)'s followed by an optional rest argument.
Transforms into...

(define (name arg ... #!optional (optional-arg value) ... #!rest rest) body ...)

I managed something similar in Chicken 3 + syntax-case (with an extra level of parens around optional arguments) but cannot figure how to do the same in Chicken 4.  I can't find any documentation (at least that I can understand) on explicit renaming macros.  The Chicken 3 code I had is below, but it doesn't work in 4.

(use syntax-case)
(define-syntax def
  (syntax-rules (*args)
    ((def (name arg ... ((opt val) ...) *args) body ...)
      (define (name arg ... #!optional (opt val) ... #!rest args) body ...))))

Any help would be appreciated, this is starting to make my head hurt :)
Jack Trades

reply via email to

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