|
From: | Mathieu |
Subject: | [Chicken-users] Macro returning multiple nodes? |
Date: | Sat, 20 Sep 2014 21:11:53 -0400 |
Hi everyone,
Writing macros with the er-macro-transformer syntax has been a charm so far. But I am now trying to accomplish something that might not make sense. I would like to use the following syntax in my code: ;; make the get-session-response (make-get-session-response (get-record-values (session-row session-id name start-date weeks-count))) And have it expended to: ;; make the get-session-response (make-get-session-response (session-row-session-id session-row) (session-row-name session-row) (session-row-start-date session-row) (session-row-weeks-count session-row)) That would somehow imply having a macro node replaced by multiple sequential nodes in the AST. My best guess so far would be: (define-syntax get-record-values (er-macro-transformer (lambda (exp rename compare) ;; parse the _expression_ (let* ((record-_expression_ (cadr exp)) (record-symbol (list-ref record-_expression_ 0)) (record-values (cdr record-_expression_))) ;; produce the statements to get the record values `,@(map (lambda (record-value) `(,(symbol-append record-symbol '- record-value) ,record-symbol)) record-values))))) But that does not work, probably for the suspected reason mentioned above. Is that something that I could achieve? Thanks in advance, Mathieu |
[Prev in Thread] | Current Thread | [Next in Thread] |