[plt-scheme] Newbie Macro question
Hi there,
I just began to play with define-syntax and I seem to be unable to create a
macro that does this:
>(to-string MyStringToBe)
"MyStringToBe"
The closest I got was this:
(define-syntax to-string
(syntax-rules ()
((_ x) (symbol->string '|x|))))
But this does not preserve case, i.e.
>(to-string MyStringToBe)
"mystringtobe"
altough
(symbol->string '|MyStringToBe|)
returns the desidered result:
"MyStringToBe"
I have a feeling that what I want cannot be done but I do not have a clear
understanding of why. My understanding is that define-syntax creates a
syntax transformer which is applied at "expansion-time" to rewrite usages of
the macro. But I am having trouble undertanding what the macro arguments (x
in the to-string macro) are. I initially thought they were just text tokens,
but the rsult above threw me of.
Would some kind soul care to enlighten me?
Thanks in advance,
-pp