Case Sensitive, Multiline Comments

Duncan Booth duncan.booth at invalid.invalid
Fri May 27 04:24:17 EDT 2005


Dennis Lee Bieber wrote:

> On 26 May 2005 17:33:33 -0700, "Elliot Temple" <curi42 at gmail.com>
> declaimed the following in comp.lang.python:
> 
>> Thanks for the link on case sensitivity.  I'm curious about the person
>> who found case sensitivity useful though: what is it useful for?
>> 
>      Making a language run faster on slow machines since the syntax
> parsing doesn't have to do the equivalent of upper or lower casing
> anything that is not a string literal before checking for keywords or
> identifiers.
> 
>      Consider the time spent by languages like Ada and Fortran when
> they have to do case normalization every time you compile.
> 
That isn't a good argument for case sensitivity. You really aren't going to 
be able to measure a slowdown in compilation speed just because the 
compiler has to lowercase all the identifiers before using them.

What I consider good arguments for case sensitivity are:

Consistency. I've used non-case sensitive languages where the same variable 
was spelled sometimes with capitals and sometimes without. Forcing you to 
choose one case and stick to it is, IMHO a good thing. Worse, I've used 
Visual Basic where the editor will gratuitously change the case of a 
variable you just typed in because there is another occurrence of the same 
name somewhere else in a different case.

Conventions such as capitalising class names, or camelCasing can be useful. 
Again this only applies if they are used consistently.

Interoperability. Like it or not, there are other case sensitive systems 
out there. I once had the misfortune to use a Microsoft Access database 
(where lookups on indexed fields are case insensitive) to store records 
indexed by a case sensitive medical coding system. Codes in that system do 
exist which differ from other completely unrelated conditions only by the 
case of the code. The only way to handle this in a case insensitive system 
is to somehow escape each case sensitive code.

That particular example wouldn't necessarily apply to a case insensitive 
programming language, but plenty of others would: e.g. using a remote 
procedure call system to call a (case sensitive) function on another 
system.

In all such cases, the case insensitive system is the 'poor relation', it 
is the one where you have to introduce workrounds in order to communicate 
with the case sensitive system. Going in the other direction (calling a 
case insensitive function from a case sensitive system) you simply have to 
invent a convention (e.g. lowercase everything) and stick by it.

There are arguments that, especially for beginners, case sensitivity 
introduces an extra level of complexity, but the cost of losing this 
complexity would be to make Python a poor relation amongst programming 
languages.



More information about the Python-list mailing list