|
From: | Răzvan Rotaru |
Subject: | Re: [Chicken-users] struggling with macros |
Date: | Sun, 11 Nov 2012 14:24:17 +0100 |
On Sun, Nov 11, 2012 at 01:23:13PM +0100, Răzvan Rotaru wrote:
> Hi,
Hi!
It's doing this correctly, is it?
> I'm trying to write a simple _javascript_ DSL, and got stuck in the macros
> :). (I'm coming from lisp macros) Take for example this one:
>
> (define-syntax js
> (ir-macro-transformer
> (lambda (expr inject compare)
> (let ((body (cdr expr)) (next (cadr expr)))
> (printf "next=~a~n" next)
> (cond
> [(string? next) (string-append "\"" next "\"")]
> [(number? next) (number->string next)]
> [(null? next) ""]
> [(list? next) `(string-append (js ,(car next)) "(" ")")]
> )))))
>
> It is supposed to handle numbers and function calls, without building the
> parameter list in the function calls.
You're trying to use MAP on a macro. That's not possible because
macros are not first-class (this is true in Common Lisp as well).
I don't understand what you're trying to do here.
[Prev in Thread] | Current Thread | [Next in Thread] |