On 11 November 2012 13:30, Peter Bex <peter....@xs4all.nl> wrote: > On Sun, Nov 11, 2012 at 01:23:13PM +0100, Răzvan Rotaru wrote: > > Hi, > > Hi! > > > 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. > > It's doing this correctly, is it? >
Yes, behaviour is correct, but implementation is not complete, hence the next version of js-macro. > 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). > Well, essentially what I have here is a macro calling itself. How can I do that? I don't understand what you're trying to do here. > I am trying to build a javascript DSL, similar to parenscript. The code above is very simple and should behave like this: (js 123) => "123" (js "123") => "\"123\"" (js (1 2 3)) => "1(2, 3)" The first two are primitives, the last is a function call. For simplicity, I ignored the comma that separates parameters in the function call. So the output I'm expecting from my code is actually: (js (1 2 3)) => "1(23)" Răzvan
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users