mixed solution: unicase (unique allowed case) (was: Re: Case-sensitivity: )

Johannes Nix Johannes.Nix at mail.uni-oldenburg.de
Fri Jun 2 15:41:12 EDT 2000


Andrew Henshaw <andrew.henshaw at gtri.gatech.edu> writes:

> require it.  In my opinion, that's the way programming should work.  I would
> like to read a program that followed case usage for readability; but, I
> don't want an interpreter to barf when case is ignored.  
> 

why don't turn it this way to get advantages of both alternatives:

- the language is case sensitive.

- an assignment to the same name with different case in the same
module is a Case Error exception.


Then, you would have to use matching case names (You can use the case
for readability or personal taste, or carrying extra information. You
can also do it all-lowercase or all-uppercase).

But you would _not_ allow any programmer to distinguish names only by
case (which in my eyes is not the best style, and most probably a
mistake which leads to a name error anyway). A small percentage of
code would have to be fixed up. (And this could be done
automatically).

A beginner couldn't ignore any more the mistake to refer to the same
name with different case, meaning the same variable. Rapid, clear and
consistent feedback is the best way to learn.

Err, if it becomes overly annoying, you could turn off the exception
with a switch to get only a less annoying warning. Semantics doesn't
change, but you will have to clean up your program afterwards if you
want to run it without switch. Also, you could automate this step
perfectly in a beginners development environment because you won't
have case clashes, e.g. you substitute all variations of a name with
the casing of the first occurrences.

As a plus, every beginner will be eager to show expertise to have
intelligently cased code!

Let's play around with the idea!

Johannes




More information about the Python-list mailing list