Search code examples
listracketquoter5rs

Racket - turns symbols in quoted list to lowercase automatically


I have the following program in Racket with the language set to "determine from source" and output syntax set to "write":

#lang r5rs
(define g '((w C C) (x A C) (y A B) (z B C)))

When I run it and type in the interactive prompt

> g

I get

{{w c c} {x a c} {y a b} {z b c}}

However, when I type the list directly to the prompt I get

> '((w C C) (x A C) (y A B) (z B C))
{{w C C} {x A C} {y A B} {z B C}}

How can I prevent Racket from turning the symbols to lowercase?


Solution

  • The R5RS standard requires the reader to hand symbols without case sensitivity. Most R5RS implementations will convert symbols with upper case symbols into lower case. If you need to produce a symbol with upper case letters, you need to use string->symbol.

    > (string->symbol "Hello")
    Hello
    

    Since many Scheme implementations supported case sensitivity, later standards changed the default to case sensitivity.

    See the (first!) question in the Scheme FAQ for a longer explanation:

    http://community.schemewiki.org/?scheme-faq-language