Subject: Re: A Question about DEFPACKAGE syntax
From: (Rob Warnock)
Date: Fri, 28 Dec 2007 21:16:02 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
[I was going to stay out of this, but since no-one has mentioned it yet...]

Robert Uhl  <> wrote:
| Rainer Joswig <> writes:
| > * "FOO" is robust against read-table changes. "FOO" stays uppercase.
| >   :foo might be interned as lowercase.
| That's an interesting definition of 'robust,' since presumably if one
| _does_ fiddle with the readtable then one _wants_ read-in code to Do the
| Right Thing.

To me, other than the default :UPCASE the only variant of READTABLE-CASE
that "Does The Right Thing" [for some definition of "Right"] is
:INVERT, which takes stuff the way we normally code it in Lisp and
uppercases it so that <<car>> is still (find-symbol "CAR") so the
code doesn't break... but *also* preserves the case of CamelCase
symbols, which can be very useful when reading a bunch of externally-
generated files. My favorite example is EDIF [".edif" or ".EDN"]
electronics design file format, which is basically just one huge
S-expr [often megabytes!] with case-sensitive symbols.

| > * Most Lisp functions print package and symbol names in uppercase.
| >   Should I downcase and 'keywordify' them if I generate code?
| (setf *print-case* :downcase)
| This is the most absolutely wonderful thing in the world, making Lisp
| look sane and intelligent (as opposed to all-caps, which is a work of
| the devil) IMHO.

No, no, no! (setf (readtable-case *readtable*) :invert) is better!  ;-}
The printer looks at *both* READTABLE-CASE and *PRINT-CASE* and
"Does The Right Thing" when the former is :INVERT and the latter
is :UPCASE, namely, re-inverts on printing. So your Lisp still
looks "sane and intelligent" but doesn't lose any information
due to case-folding:

    > (setf (readtable-case *readtable*) :invert)

    > (list 'foo 'BAR 'Baz 'CamelCase)

    (foo BAR Baz CamelCase)
    > (mapcar #'symbol-name *)

    ("FOO" "bar" "Baz" "CamelCase")

| > * many tools (inspector, debugger, pretty printer, grinder, ...)
| >   will show uppercase symbols and uppercase symbol names.
| See above.  The only place I see ugly, perverse capital letters is in
| SBCL error messages, which impolitely ignore *print-case*.

CMUCL, at least, "Does The Right Thing" [by your definition]
namely, still re-inverts the case during error messages.

So try leaving *PRINT-CASE* alone [that is, in the default :UPCASE],
and see how READTABLE-CASE :INVERT works for you...


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607