Next: Argument Conventions of Some Reader Functions, Previous: Dynamic Control of the Lisp Reader, Up: Reader Concepts
The readtable case of the current readtable affects the Lisp reader in the following ways:
When the readtable case is :upcase,
unescaped constituent characters are converted to uppercase,
as specified in Section 2.2 (Reader Algorithm).
When the readtable case is :downcase,
unescaped constituent characters are converted to lowercase.
When the readtable case is :preserve,
the case of all characters remains unchanged.
When the readtable case is :invert, then if all of the unescaped letters in the extended token are of the same case, those (unescaped) letters are converted to the opposite case.
(defun test-readtable-case-reading () (let ((*readtable* (copy-readtable nil))) (format t "READTABLE-CASE Input Symbol-name~ ~%-----------------------------------~ ~%") (dolist (readtable-case '(:upcase :downcase :preserve :invert)) (setf (readtable-case *readtable*) readtable-case) (dolist (input '("ZEBRA" "Zebra" "zebra")) (format t "~&:~A~16T~A~24T~A" (string-upcase readtable-case) input (symbol-name (read-from-string input)))))))
The output from (test-readtable-case-reading)
should be as follows:
READTABLE-CASE Input Symbol-name ------------------------------------- :UPCASE ZEBRA ZEBRA :UPCASE Zebra ZEBRA :UPCASE zebra ZEBRA :DOWNCASE ZEBRA zebra :DOWNCASE Zebra zebra :DOWNCASE zebra zebra :PRESERVE ZEBRA ZEBRA :PRESERVE Zebra Zebra :PRESERVE zebra zebra :INVERT ZEBRA zebra :INVERT Zebra Zebra :INVERT zebra ZEBRA