| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Historically, most Lisp-family languages are case-insensitive for symbols. Scheme is no exception and R5RS defines symbols are read in case-insensitive way. (Note that symbols are case-sensitive internally even in R5RS Scheme; case-insensitivity is about readers.)
However, nowadays programming is hardly completed in one language. When you have to interact with other languages that distinguish uppercase and lowercase characters, it is desirable that Scheme distinguishes them as well.
So Gauche has two modes in reading and writing symbols. By default, Gauche reads and writes symbols in case-sensitive manner. This behavior doesn't conform R5RS.
; In case-sensitive mode (default) (eq? 'a 'A) ⇒ #f ; #t in R5RS (symbol->string 'ABC) ⇒ "ABC" (symbol->string 'abc) ⇒ "abc" (display (string->symbol "ABC")) ⇒ writes ABC (display (string->symbol "abc")) ⇒ writes abc |
You can make Gauche case-insensitive by giving -fcase-fold
command-line option to the gosh interpreter (See section Invoking Gosh).
In this mode, the reader folds uppercase characters in symbols to lowercase
ones. If a symbol name contains uppercase characters, it is written
out using |-escape (See section Symbols).
; In case-insensitive mode (with -fcase-fold option) (eq? 'a 'A) ⇒ #t (symbol->string 'ABC) ⇒ "abc" (symbol->string 'abc) ⇒ "abc" (display (string->symbol "ABC")) ⇒ writes |ABC| (display (string->symbol "abc")) ⇒ writes abc |
Alternatively, if the reader sees a token #!fold-case,
the reader switches to case-insensitive mode. A token
#!no-fold-case has an opposite effect—to make the
reader case-sensitive. These tokens affect the port
from which they are read, and are in effect until EOF
or another instance of these tokens are read.
See Lexical structure for more details on #! syntax.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.