[plt-scheme] Newbie Macro question

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Mar 28 21:21:25 EST 2003

Your understanding is right on. The problem is that case-insensitivity
is implemented by the reader (aka lexer) downcasing everying.

Robby

At Fri, 28 Mar 2003 20:42:49 -0500, "Pedro Pinto" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> 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
> 
> 



Posted on the users mailing list.