Subject: Re: Lisp modularization
From: (Rob Warnock)
Date: Sat, 04 Jul 2009 06:02:53 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
D Herring  <> wrote:
| Rob Warnock wrote:
| > Doing (setf (readtable-case *readtable*) :invert) will do much the
| > name thing, but without losing information in case you have some
| > mixed-case symbols in your environment.
| True, but :invert is a braindead, clever hack by people who refuse to 
| move forward with life.  I don't much like it, but don't see anything 
| better without changing CL's core.  And it doesn't even work all the 
| time; try typing a cl: symbol with CamelCase...

I'm not sure what you mean by "doesn't even work all the time".
It works as documented in the CLHS:

    23.1.2 Effect of Readtable Case on the Lisp Reader
	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.

and: Effect of Readtable Case on the Lisp Printer
	When the readtable case is :invert, the case of all
	alphabetic characters in single case symbol names is
	inverted. Mixed-case symbol names are printed as is.

To wit:

    > (readtable-case *readtable*)

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

    > (defun show (sym)
	(list sym (symbol-name sym)))

    > (show 'cl::foo)

    (common-lisp::foo "FOO")
    > (show 'cl::FooBar)

    (common-lisp::FooBar "FooBar")
    > (show 'cl::FOO)

    (common-lisp::FOO "foo")

Now you might not *like* the documented behavior, but it's useful
when one needs to read sexps from files written in CamelCase [e.g.,
EDIF files] when what one mostly wants is read/print invariance
together with the ability to still input symbols in the CL package
in lowercase.


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