[plt-scheme] Newbie Macro question

From: Pedro Pinto (ppinto at cs.cmu.edu)
Date: Fri Mar 28 20:42:49 EST 2003

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)

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)


(symbol->string '|MyStringToBe|)

returns the desidered result:


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,

Posted on the users mailing list.