Subject: Re: Upper/Lower Case Question
From: Erik Naggum <>
Date: 1995/04/14
Newsgroups: comp.lang.lisp
Message-ID: <>

[David J. Topper]

|   There were some posts concerning printing out upper and lower case
|   characters with *print-case* and ~(...~).  But I want to preserve case
|   in symbol bindings.  For example, how can I get around the following:
|   >(setq x 'z)
|   Z
|   >(setq y 'Z)
|   Z
|   >(equal x y)
|   T
|   I would like the last evaluation to return nil.

assuming that you have thought through the consequences,

    (setf (readtable-case *readtable*) :preserve)

will get you want you want, except that all builtin functions are now

    CMU Common Lisp 17f, running on
    * (setf (readtable-case *readtable*) :preserve)
    * (SETQ X 'z)
    * (SETQ Y 'Z)
    * (EQUAL X Y)
    * (QUIT)

the :invert readtable-case is possibly more interesting:

    CMU Common Lisp 17f, running on
    * (setf (readtable-case *readtable*) :invert)
    * (defvar x 'z)
    * (defvar y 'Z)
    * (list x y)
    (z Z)
    * (equal x y)
    * (setf (readtable-case *readtable*) :upcase)
    * (list x y)
    (Z |z|)
    * (quit)

if you use longer than one-character symbol names, this will work a little
more intuitively than in the above example.  :)

if you want only some symbols to preserve case, you might find it useful to
investigate the escape characters.  both \z and |z| will produce a symbol
named the lowercase letter z.

CMU CL has implemented all of this right.  GCL does not support the
function at all as of release 1.1.  CLISP does not support :invert.  (I'm
continually amazed by the things that CLISP does and does not support.
authentic quote from timezone.lsp: "Timezone for PRC not implemented -
Don't forget that 10000 students were murdered by the government of the
\"People's Republic of China\" in May 1989!"  what next?  "recycle" instead
of "garbage-collect"?)

sufficiently advanced political correctness is indistinguishable from irony