Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Upper/Lower Case Question

28 views
Skip to first unread message

David J. Topper

unread,
Apr 14, 1995, 3:00:00 AM4/14/95
to
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

Bruno Haible

unread,
Apr 14, 1995, 3:00:00 AM4/14/95
to
David J. Topper <top...@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
hai...@ma2s2.mathematik.uni-karlsruhe.de


Erik Naggum

unread,
Apr 14, 1995, 3:00:00 AM4/14/95
to
[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

Message has been deleted

Erik Naggum

unread,
Apr 22, 1995, 3:00:00 AM4/22/95
to
[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.

0 new messages