Case sensitivity

Alex Martelli aleax at aleax.it
Sat Feb 22 01:05:50 CET 2003


Erik Max Francis wrote:
   ...
> But he gave you an example (Coke vs. coke), where the difference in
> capitalization matters _enormously_.  You just chose to ignore it in

Sez you.  Walk into any bar and order "a coke".  What will they
serve you?  Oh you say they can't HEAR you miscapitalized it?  Well,
well -- what a surprise!  OK, say the din in the bar is so
terrible you have to jot down your order on paper -- do you
really think the bartended will be nonplussed if you write

   A COKE

or
   a coke

rather than painfully mixing case?  Human beings aren't really
case-sensitive, unless they're being deliberately pedantic for
the purpose of irking you...

> deference to your case-preserving (but not sensitive) examples.  There
> are many other examples of situations where case sensitivity matters
> enormously.  Pointing out that sometimes it doesn't doesn't surprise
> anyone.

Surprising cases would be those where human beings WOULD be
case-sensitive -- i.e., couldn't communicate about something
in spoken language (where there's no capitalization heard)
and would HAVE to write things down (with proper caps of
course).  We've had (spoken) language for (say) 100,000 years
(probably more), written language for maybe 5,000 (if that)
and case distinction for a FEW languages for a PART of that
(relative) blink of an eye, so that's pretty obvious...


> My fundamental point when people talk about case-insensitive languages
> is this:  If there's no distinction between case made in the language,
> why let the user make it at all?  All it allows users to do is to use
> differing case conventions that will confuse everybody.

There is no distinction between e.g. f(x+y,z,t) written without any
spaces and e.g. f(x+y, y, z) written with normal spacing conventions,
so why let the user write both forms?  Answer: be generous in what
you accept (and conservative in what you generate).  There is NO
harm done in accepting the form with the spaces that some users will
think make their code more readable when well-used (I'm among those
users).  Similarly, in a non case-sensitive language, there is no
harm done in accepting the user's preferred capitalization.

So what's your position regarding use of optional spaces within
expressions?  Or what mirrors will you choose to climb in order
to "prove" that accepting all variants of optional spaces is
best but accepting variants of capitalization would not be, when
the two situations are so obviously similar?


> Particularly in languages (including Python) where case formatting is
> often used as a convention to give a hint as to what type of thing
> something is (e.g., all uppercase is probably intended to be a
> constant).

But math.pi shows that the "convention" is one-way -- constants
may perfectly well be indicated with NON-all-uppercase spelling.

So why "scream abuse" at the poor user who thinks it should be
spelled math.PI (raising an error IS perceived by the typical
beginner as such "abuse";-)?  He or she is just more consistent
than the Python library designers -- *why diminish his or her
productivity by insisting that the fact that math.py is lowercase
MUST be memorized, or checked each and every time*?!


Alex





More information about the Python-list mailing list