Subject: Re: Lisp modularization
From: (Rob Warnock)
Date: Sat, 04 Jul 2009 19:32:44 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
D Herring  <> wrote:
| Rob Warnock wrote:
| > I'm not sure what you mean by "doesn't even work all the time".
| > It works as documented in the CLHS:
| Please ignore my error wrt CamelCase for a moment.  The thing that 
| really bothers me with :invert is that it hides a dirty secret; 
| everything that touches the internal representation must participate 
| or things will break.

Agreed, but then again, that's usually the case when one
"touches the internal representation" of almost anything...  ;-}  ;-}

Look, I was just quibbling over calling :INVERT "broken" when
in fact it does "work" as ANSI CL requires.

Now if you want to call ANSI CL *itself* "broken" for not having gone
with a full case-sensitive symbol reader as the default -- instead
of picking the historical :UPCASE as the default and then slipping
in :INVERT as a clumsy hack for preserving read/write case-invariance
while not breaking source code written in lowercase -- well, that's
a whole 'nother argument, one that continues from time to time [as
Professor Fateman points out in his parallel reply], for example,
the [sometimes rancorous!] discussions of Allegro Common Lisp's
"modern" mode a while back.

And by the way, I never meant to imply that :INVERT completely
"solves" the problem; it only ameliorates it under most
circumstances... and makes things worse in others. For example,
I've seen plenty of legacy CL code that, while written *mostly*
in lowercase, for stylistic & readability reasons freely uses
both uppercase and lowercase to designate the *same* symbol.
E.g., the CMUCL compiler sources tend to make tags in TAGBODYs
and VOP bodies [think LAP] be all uppercase, while *not* always
making all references to them be the same. [Though to be fair,
that "mismatch" mostly occurs in VOPs; in TAGBODYs the authors
*did* mostly say (go FOO) to go to FOO and (go bar) to go to bar.]

So you still have to be careful when using :INVERT. That said,
given that ANSI CL defaults to :UPCASE, I'm still glad :INVERT
is available [and think that :PRESERVE is almost *never* the
right thing to use!!]..

| ...[example elided]...
| Note how :invert breaks the algebra of treating symbol names as 
| strings?  The CL API leaks this implementation detail.

But no such "algebra of treating symbol names as strings" was ever
promised by the standard. That is, I would claim that this isn't
"leaking an implementation detail", it's quite clearly adhering to
the published spec [which in turn was a compromise of the times].

| >     23.1.2 Effect of Readtable Case on the Lisp Reader
| >     ...
| >     :invert
| > 	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.
| Why not always invert?  Why the special behavior for CamelCase? 

Simple: historical compatibility with legacy code containing *lots*
of uppercase strings in symbol contexts: (intern "FOO" "BAR"),
(in-package "GORP"), etc.

| In this day and age, it is customary to write IN LOWERCASE; it seems 
| like CL AND OLD FORTRAN are the only languages which don't comply.

A sizable number of people agree with you. [See many previous threads
in this group.] Neverthless, as we all know, ANSI CL is a *compromise*
standard reflecting the practices and -- most importantly -- the existing
corpus of code at that time, and as a result :UPCASE was chosen as
the default.

| It seems to me that :invert was the ugly hack which made ALL CAPS 
| acceptable in the CL spec; I often wish it hadn't been invented.

You've got it backwards, I think. Given that :UPCASE *was* chosen as
the default [which made (eq 'ALL-CAPS 'all-caps) not only "acceptable"
but mandatory, by default], :INVERT was the ugly hack glued on afterwards
to provide *some* measure of read/write mixed-case stmbol invariance
while not totally breaking code written in all lowercase. So *given*
:UPCASE as the default, I personally am glad that :INVERT exists.


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