[Top][All Lists]

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

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

From: Jack Trades
Subject: Re: [Chicken-users] Re: Explicit Renaming Macros Help/Tutorial?
Date: Mon, 8 Jun 2009 16:13:20 -0400

On Mon, Jun 8, 2009 at 6:34 AM, felix <address@hidden> wrote:
Jack Trades <jacktradespublic <at>> writes:

> 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


This should get you going:

(define-syntax (def x r c)
 (let ((%define (r 'define))
       (head (cadr x))
       (body (cddr x)))
       (car head)
       (let loop ((args (cdr head)) (req '()) (opt '()))
         (cond ((null? args)
                (append (reverse req) (reverse opt)))
               ((list? (car args))
                (loop (cdr args)
                      (cons (car args)
                            (if (null? opt)
               ((pair? opt)
                (if (null? (cdr args))
                    (append (loop '() req opt) `(#!rest ,(car args)))
                    (syntax-error 'def "invalid lambda-list" head)))
               (else (loop (cdr args) (cons (car args) req) opt)))))

(this is probably totally wrong, but you get the idea)

Also have a look here:


Chicken-users mailing list

Thanks, that's exactly what I was looking for.  Now that I know how it applies to my problem I shouldn't have too much trouble figuring the rest out.  I really appreciate your help.

Jack Trades

reply via email to

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