[plt-scheme] getting argument identifiers
Stephen De Gabrielle wrote:
> What I was trying to do was define a macro that would dump whatever I
> stuffed into it. (instead of using printf functions all through my
> code)
> It can get unwieldy so I wanted to print the identifiers too.
>
> (define-syntax dump-all
> (syntax-rules ()
> [(_ x ...)
> (begin
> (printf "Dump:~N")
> (for-each
> (lambda (i) (printf "item:~n~v~n" i))
> (list x ...))
> (printf "Dump End~n")
> )]))
>
> (define x "dfd")
> (dump-all 2 4 x)
>
Do you mean something like this?
#lang scheme
(define-syntax dump-all
(syntax-rules ()
[(_ x ...)
(begin
(for-each (lambda (e v) (printf "expression: ~v value: ~v ~n" e v))
'(x ...)
(list x ...)))]))
(define x "dfd")
(dump-all 2 4 x)
which prints
expression: 2 value: 2
expression: 4 value: 4
expression: x value: "dfd"
?
--
Jens Axel Søgaard