From: David J. Topper
Subject: Upper/Lower Case Question
Date: 
Message-ID: <Pine.SUN.3.91.950414125759.27651A-100000@panix.com>
Hello,

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.

Thanks,

Dave Topper

From: Bruno Haible
Subject: Re: Upper/Lower Case Question
Date: 
Message-ID: <3mmcnc$2m0@nz12.rz.uni-karlsruhe.de>
David J. Topper <······@panix.com> wrote:
> But I want to preserve case in symbol bindings.  For example, how can
> I get around the following:
>
> >(setq x 'z)
> >(setq y 'Z)
> >(equal x y)
> T
>
> I would like the last evaluation to return nil.

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

But then you will have to write (SETQ x 'z), (SETQ y 'Z), (EQUAL x y)
and so on, because the predefined Common Lisp symbols come in upper case.


                    Bruno Haible
                    ······@ma2s2.mathematik.uni-karlsruhe.de
From: Erik Naggum
Subject: Re: Upper/Lower Case Question
Date: 
Message-ID: <19950414T181207Z.enag@naggum.no>
[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
uppercase:

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

the :invert readtable-case is possibly more interesting:

    CMU Common Lisp 17f, running on naggum.no
    * (setf (readtable-case *readtable*) :invert)
    :invert
    * (defvar x 'z)
    x
    * (defvar y 'Z)
    y
    * (list x y)
    (z Z)
    * (equal x y)
    nil
    * (setf (readtable-case *readtable*) :upcase)
    :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"?)

#<Erik>
--
sufficiently advanced political correctness is indistinguishable from irony
From: Simon Brooke
Subject: Re: Upper/Lower Case Question
Date: 
Message-ID: <D7CnI6.3ro@rheged.dircon.co.uk>
In article <·····················@naggum.no>,
Erik Naggum  <····@naggum.no> wrote:
>the :invert readtable-case is possibly more interesting:
>
>    CMU Common Lisp 17f, running on naggum.no
>    * (setf (readtable-case *readtable*) :invert)
>    :invert
>    * (defvar x 'z)
>    x
>    * (defvar y 'Z)
>    y
>    * (list x y)
>    (z Z)
>    * (equal x y)
>    nil
>    * (setf (readtable-case *readtable*) :upcase)
>    :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.  :)
>

H'mmm ... this is a trick I haven't seen before, and could make CL a
damn sight more tolerable (I *hate* a language which only knows how to
shout). Before I start madly into it, what are the disadvantages and
gotchas of using this as a standard working mode?



-- 
------- ·····@rheged.dircon.co.uk (Simon Brooke)

			-- mens vacua in medio vacuo --
From: Erik Naggum
Subject: Re: Upper/Lower Case Question
Date: 
Message-ID: <19950422T211047Z.enag@naggum.no>
[Simon Brooke]

|   H'mmm ... this is a trick I haven't seen before, and could make CL a
|   damn sight more tolerable (I *hate* a language which only knows how to
|   shout).  Before I start madly into it, what are the disadvantages and
|   gotchas of using this as a standard working mode?

:invert has its dangers.  any use of uppercase letters will turn them into
lowercase letters in the symbol names, and you may not want that, but
perhaps :downcase will work as you want.  I bind *print-case* to :downcase,
and find this very convenient.

#<Erik>
--
sufficiently advanced political correctness is indistinguishable from irony