I've got this macro:
(define-syntax inspect
(syntax-rules ()
[(_ x) (printf "~a is: ~a\n" 'x x)]))
Which works like so:
(let ([x 2]) (inspect x))
>> x is: 2
But what I'd like to do is extend it so that I have
(_ x ...)
and loop through the various values providing, printing out their variable names and values accordingly.
ie
(let ([x 2] [y 3]) (inspect x y))
>> x is: 2
y is: 3
I'm a bit stuck on this part.
For example, with something like this:
(define-syntax (inspect stx)
(datum->syntax
stx
(for ([i (cdr (syntax->list stx))])
(printf "~a is: ~a" (syntax->datum i) i))))
I'm unsure how to get at the value of i, on the last line.
Any help is appreciated.
Thanks.