[comp.lang.c] Explanation of "Case-sensitive"

jskuskin@eleazar.dartmouth.edu (Jeffrey Kuskin) (04/22/89)

I didn't realize this would lead to so much debate ...

What I meant by "Why is C case-sensitive" is *NOT* "Why do C compilers
accept mixed-case source files as input, as opposed to requiring single-case
(all upper case, say) source files"  A compiler in this day and age which
required single-case source files would (I hope) be considered
badly outdated.

What I *DID* mean is:  "Why does the C language specify that keywords,
identifiers, etc. be distinguished by case as well as by spelling."

A quick example will clarify:

In Pascal (a case-insensitive language by my definition), "myVar := 2"
is the same as "mYvAR := 2"

In C, of course, "myVar = 2" is not the same as "mYvAR = 2"; "myVar" and
"mYvAR" are 2 distinct variables because they differ in case, even though
they are spelled identically.

Why was C specified this way?  A case-insensitive language puts no
restrictions on source-file formatting:  symbolic constants can be
all upper case, variables all lower case, functions mixed-case, etc.
The only difference comes at compile time when silly errors (IMHO)
such as "mYvAR not declared" start to appear (when you *have* declared
"myVar").

-- Jeff Kuskin, Dartmouth College

EMAIL:  jskuskin@eleazar.Dartmouth.EDU

ddv@Solbourne.COM (Dan DeVries) (04/23/89)

I'm suprised this hasn't come up.

In (K&R) p179 it states that external identifiers may be constrained
by the loader.  It gives 2 examples (IBM,Honeywell) where the loader
only uses one case.  Therefore, the argument about increased naming
space is not true for external identifiers (assuming portable code is
desirable).  The loader may map Tree and tree to the same identifier.

I have yet to here a good argument for cases being distinct, and have
seen several that say it's a bad idea.  So, once again:

Why is C case sensitive?  And who can we blame for this mistake?

gwyn@smoke.BRL.MIL (Doug Gwyn) (04/23/89)

In article <860@tp.Solbourne.COM> ddv@Solbourne.com (Dan DeVries) writes:
>I have yet to here a good argument for cases being distinct, and have
>seen several that say it's a bad idea.  So, once again:
>Why is C case sensitive?  And who can we blame for this mistake?

Sorry, if you can't understand what you read then why should we waste
more words on you?

It is NOT a mistake.

campbell@redsox.UUCP (Larry Campbell) (04/23/89)

In article <860@tp.Solbourne.COM> ddv@Solbourne.com (Dan DeVries) writes:
-
-Why is C case sensitive?  And who can we blame for this mistake?

It is NOT a mistake.  Why do you insist that it is?  Why is it so hard
for you to spell your identifiers correctly?  Why do you want to spell
the same identifier many different ways?  What possible advantage would
this convey?
-- 
Larry Campbell                          The Boston Software Works, Inc.
campbell@bsw.com                        120 Fulton Street
wjh12!redsox!campbell                   Boston, MA 02146

tainter@ihlpb.ATT.COM (Tainter) (04/24/89)

In article <13174@dartvax.Dartmouth.EDU> jskuskin@eleazar.dartmouth.edu (Jeffrey Kuskin) writes:
>What I *DID* mean is:  "Why does the C language specify that keywords,
>identifiers, etc. be distinguished by case as well as by spelling."

>Why was C specified this way?  A case-insensitive language puts no
>restrictions on source-file formatting:  symbolic constants can be
>all upper case, variables all lower case, functions mixed-case, etc.
>The only difference comes at compile time when silly errors (IMHO)
>such as "mYvAR not declared" start to appear (when you *have* declared
>"myVar").
But you haven't!

Compiling is exactly when you want to find these!  Every instance of this indicates
a poorly understood piece of code and a bug waiting to bite you.  Do you also
recommend using Thisisasymbolofgreatlength and Thisisasymbol and expect them to
be equal just because your compiler truncates symbols?

To return to your argument:
Consider the fact that we capitalize the first letter of sentences (in English,
sorry all you other native language speakers).  Why?  Because there is additional
information important to the understanding of the statement which we wish to
convey.  The same is true with programming languages.  I contend that "Why?"
and "why?" are not the same.  The first is a quoted question, the latter is just
a quoted question fragment.  That additional information is critical.  Just as
the use of case in your programming should be.

>-- Jeff Kuskin, Dartmouth College

--johnathan.a.tainter--
   att!ihlpb!tainter

rob@phavl.UUCP (Robt. I. Ransbottom) (04/24/89)

In article <860@tp.Solbourne.COM>, ddv@Solbourne.COM (Dan DeVries) writes:
> [...]
> Why is C case sensitive?  And who can we blame for this mistake?

Why waste the cycles.
Who?  Thompson & Ritchie get the credit for this.

I can't recall any required use of uppercase in C.  tolower your source
into cc if you wish.

-- 
 ...!uunet!phavl!rob              Robert Ransbottom

krazy@claris.com (Jeff Erickson) (04/24/89)

> I have yet to here a good argument for cases being distinct, and have
> seen several that say it's a bad idea.  So, once again:
> 
> Why is C case sensitive?  And who can we blame for this mistake?

In my opinion, one of the easiest ways to make Pascal code unreadable is to
capitalize all the keywords.  I find the line "IF foo = 3 THEN BEGIN" much more
distracting than the equivalent "if (foo = 3) then begin".

This is one of the best arguments (IMHO) for requiring that C keywords be
entered in lower case.  I don't want to be distracted by semantic sugar
when I'm trying to figure out what a piece of code does.  (Oh, god, I see
a flame war coming.  Please, no!!)

I tend to try to conform to a standard capitalization scheme when I enter
identifiers.  (e.g., CONSTANT, TypeName, variable, function()).  I don't want
any confusion about what something is.  If I see all upper case, it means
constant.  If I try to type the same identifier in lower case, I want the 
compiler to flag that as an error.  

I prefer my languages (and operating systems) to be completely case-sensitive.
"A" is not the same as "a" to me when I'm on the computer.

Your mileage may vary, and will be lower in California.  To each their own.


-- 
Jeff Erickson       Claris Corporation  | Birdie, birdie, in the sky,
408/987-7309      Applelink: Erickson4  |   Why'd you do that in my eye?
krazy@claris.com     ames!claris!krazy  | I won't fret, and I won't cry.
       "I'm a heppy, heppy ket!"        |   I'm just glad that cows don't fly.

peter@ficc.uu.net (Peter da Silva) (04/24/89)

In article <13174@dartvax.Dartmouth.EDU>, jskuskin@eleazar.dartmouth.edu (Jeffrey Kuskin) writes:
> Why was C specified this way?  A case-insensitive language puts no
> restrictions on source-file formatting:  symbolic constants can be
> all upper case, variables all lower case, functions mixed-case, etc.

Neither does a case-sensitive language. In fact, the draft Ferranti coding
standard for 'C' makes such a distinction. If you're consistent, you win.
If you're inconsistent, then you win (oh, I should have called it MyVar,
now shouldn't I?).

> The only difference comes at compile time when silly errors (IMHO)
> such as "mYvAR not declared" start to appear (when you *have* declared
> "myVar").

Why would you do that?

How about confusing "Ile", "lIe", and "IIe"? Silly errors.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.

Business: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter@sugar.hackercorp.com.

eriks@cadnetix.COM (Eriks A. Ziemelis) (04/24/89)

First off, "Why is C case sensitive?", here's my partial guess. As stated
in the "bible", page ix: "C was originally designed for and implemented
on the UNIX* operating system..." Well funsters, we all know how UNIX 
command shells work. It would have been ugly: get into VI, get into append
or insert, cap lock keys, type C code, <esc>, uncap lock, VI command,
cap lock, and on and on. Oh yeah, don't forget to un-cap lock after
you get out of VI, those UNIX commands tend to be in lower case \'-)

As someone else pointed out, debugging someone elses code would be a 
joy. MyVar == mYvAR could make life ugly for someone that doesn't
search for vars in the source case insensitive.

As for personal preference, I want case sensitive. This way, I can
have multiple versions of the same function in code/library, same
calling sequence, each one tweeked internally for debug/test purposes:
foo1() is the released version, Foo1() is test version 1, FOO1() test
version2...

In article <738@redsox.UUCP> campbell@redsox.UUCP (Larry Campbell) writes:
>
>It is NOT a mistake.  Why do you insist that it is?  Why is it so hard
>for you to spell your identifiers correctly?  Why do you want to spell
>the same identifier many different ways?  What possible advantage would
>this convey?
>-- 

What he said!


Eriks A. Ziemelis


Internet:  eriks@cadnetix.com
UUCP:  ...!{uunet,boulder}!cadnetix!eriks
U.S. Snail: Daisy/Cadnetix Corp.
	    5775 Flatiron Pkwy
	    Boulder, CO 80301
Baby Bell: (303) 444-8075 X336

djones@megatest.UUCP (Dave Jones) (04/25/89)

From article <10099@smoke.BRL.MIL>, by gwyn@smoke.BRL.MIL (Doug Gwyn):
> In article <860@tp.Solbourne.COM> ddv@Solbourne.com (Dan DeVries) writes:
>>I have yet to here a good argument for cases being distinct, and have
>>seen several that say it's a bad idea.  So, once again:
>>Why is C case sensitive?  And who can we blame for this mistake?
> 
> Sorry, if you can't understand what you read then why should we waste
> more words on you?
> 
> It is NOT a mistake.


Are we sure that he did not understand?  Might it not be possible
that he has not yet received the definitive posting which you assume he
can not understand?  Sometimes I receive postings weeks or months
after they are posted.

But there is also the possibility - now try to follow this closely --
there is the possibility that he is capable of understanding postings,
but there is some difference of opinion as to what constitutes a
"good argument".

As to the question of whether you should "waste more words", the answer
is most certainly, no you should not.  But I rather suspect that you
will.


                        daVE

fieland@hobbiton.prime.com (04/25/89)

I think that the reason C is case-sensitive is that UNIX is case-sensitive,
and C was used to write the UNIX kernel. 

laba-4he@web-3d.berkeley.edu (The Cybermat Rider) (04/26/89)

In article <175100004@hobbiton> fieland@hobbiton.prime.com writes:
>
>I think that the reason C is case-sensitive is that UNIX is case-sensitive,
>and C was used to write the UNIX kernel. 

Eh?  In that case, I'd draw the conclusion that UNIX is case-sensitive
BECAUSE C is case-sensitive, not the other way around!

Anyway, I think C should be case-sensitive -- it's my personal philosophy
that one's options should always be kept open.  8-)

Seriously though, if I choose to use several identifiers in a single program
that differ only in casing, I'm making the implicit assumption that I KNOW
EXACTLY WHAT I'M DOING.  To make things simpler, I use only two casing
styles:  ALL UPPERCASE (for #define's and typedef's), and all lowercase
(everything else).

If I feel that I might screw up my capitalization somewhere down the line,
or if I can't formulate a SIMPLE (note emphasis) system that I can stick to,
I simply SAY NO TO MIXING CASES!

Those who decry C's case-sensitivity should consider this: If you can't bear
to mix cases in your code, just leave everything in lower case (unless
necessary) -- it's easier to read than CAPS, and you don't really need to
CAPITALIZE keywords to understand C code, do you?  If you're trying to read
someone else's code, you'll probably find that CAPS were used in a simple,
logical fashion (in which case you shouldn't have any trouble adapting
unconsciously to his/her system), or they weren't, in which case even the
author would probably be unable to read it after a month.

So why continue this debate?  Case sensitivity is an OPTION -- you don't
have to rely on it if you don't want to.....

I shall now descend from my soapbox and slip into my abestos suit.....

----------------------------------------------------------------------------
Adrian Ho a.k.a. The Cybermat Rider	  University of California, Berkeley
laba-4he@web.berkeley.edu		(WEB Evans, Home of The CS Freakies)
Disclaimer:  Nobody takes me seriously, so is it really necessary?

barmar@think.COM (Barry Margolin) (04/26/89)

In article <175100004@hobbiton> fieland@hobbiton.prime.com writes:
>I think that the reason C is case-sensitive is that UNIX is case-sensitive,
>and C was used to write the UNIX kernel. 

And the reason Unix is case-sensitive is that it was modeled after
Multics, which is also case-sensitive.  I suspect that the reason
Multics was made case-sensitive was that it seemed more modern.  At
the time, many computer terminals and printers were uppercase-only,
but the new-fangled IBM 2741 terminal had recently come out and it
provided lowercase.  Therefore, they decided to take advantage of the
availability of lowercase and allow case to be used to distinguish
things.

What probably would have made more sense would have been
case-preserving in things like file names; this means that case is
insignificant in lookups, but when you create a file (or user, or
whatever) the case you use is remembered (this is the scheme used in
the Macintosh file system).  But at the time there was little
experience with dual-case systems, so they probably chose the
simplest-seeming scheme.

This is getting beyond the scope of C....

Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

gwyn@smoke.BRL.MIL (Doug Gwyn) (04/26/89)

In article <175100004@hobbiton> fieland@hobbiton.prime.com writes:
>I think that the reason C is case-sensitive is that UNIX is case-sensitive,
>and C was used to write the UNIX kernel. 

There is certainly some logical connection between the two, but not
the one you've guessed.  The UNIX kernel could have been written in
a case-insensitive language and still have avoided folding case in
file names, etc.  The connection is that both software items were
produced by people with the same general philosophy about such
matters.  It is simpler to not fold cases, there is no gain in
functionality by folding cases, there is a loss of generality in
folding cases, therefore it should not be done.

tony@ajfcal.UUCP (Tony Field) (04/26/89)

I think we are finally getting close to the mark.

In article <39708@think.UUCP>, barmar@think.COM (Barry Margolin) writes:
> 
> And the reason Unix is case-sensitive is that it was modeled after
> Multics, which is also case-sensitive.  I suspect that the reason
> Multics was made case-sensitive was that it seemed more modern.
      .. etc ..

Here are a few other reasons behind the case sensitivity of c and unix:
      
C was based on B was based on BCBL. The B manual by J.S. Johnson clearly
indicated that the "ascii" character set was to be used, including the
letters A-Z and a-z.  Code portablility from b to c possibly mandated
the sensitivity to case.

Modern computers such the PDP-11 and PDP-15 easily supported full ASCII -
unlike the 80-column card based 7094, 360/40, and paper tape based 1620's.
8 bit in a byte: not 6 bit charactes.  Lets use them...

New programmes such as ROFF and RUNOFF were developed to process text. As
a result, text editors had to be case sensitive. Case-sensitive editors
encourage case sensitive programming languages. If I remember correctly,
the first experimental versions of unix were used for office automation
within Bell Labs: obviously a case-sensitive environment.

Case sensitivity would have added "lots" of unnecessary code to the
compiler and operating system support. The hundred of extra words/bytes
could be better used doing more useful functions than worrying about
case. (A 32k or 64k pdp-11 was a large system in those days)

My English teacher used to "blast me" if I capitalized incorrectly.
My compiler "blasts me" when I capitalize incorrectly.

My marks were lower if my papers were capitalized incorrectly. My
programmes don't work as well as I would like if I capitalize
incorrectly.

I guess I am just getting used to it......
-- 
+------------------------------------
|  Tony Field                             ..uunet!utai!calgary!ajfcal!tony
|  Co-Design Information Systems Ltd.
|  Calgary, Alberta, Canada                 voice: (403) 266-3239

news@ism780c.isc.com (News system) (04/27/89)

In article <10296@ihlpb.ATT.COM> tainter@ihlpb.UUCP (55529-Tainter,J.A.) writes:
>Consider the fact that we capitalize the first letter of sentences (in English,
>sorry all you other native language speakers).  Why?  Because there is additional
>information important to the understanding of the statement which we wish to
>convey.  The same is true with programming languages.  I contend that "Why?"
>and "why?" are not the same.  The first is a quoted question, the latter is just
>a quoted question fragment.  That additional information is critical.  Just as
>the use of case in your programming should be.
>
>
>--johnathan.a.tainter--
>   att!ihlpb!tainter

Using English as a model for programming languages is fraught with problems.
As some one pointed out "Polish" and polish are not even pronounced the same
way.  But look at the sentence, "Polish the car with the polish in this
bottle.  Here both versions are pronounced the same but have different
meanings.  (Did you do a double take with "Polish", I did) Now look at, "He
asked me to read the code so I read it." In that sentence there are two
occurrences of the string "read".  Each occurrence has a different meaning
and a different pronunciation.

I think the case for case sensitivity (pun intended) should be made on the
bases of whether coding is less error prone one way or the other.  This could
be determined by experiment.  (My a prori guess: no difference)

Languages prior to C allowed only one case because that is all that was
available with the hardware.  C allowed two cases because by the time C was
developed ASCII devices were common.  Now we have equipment that supports
multiple fonts.  Should a future language make a distinction between italics
and boldface?  Between small and large character size?

    Marv Rubinstein

gwyn@smoke.BRL.MIL (Doug Gwyn) (04/27/89)

In article <26749@ism780c.isc.com> marv@ism780.UUCP (Marvin Rubenstein) writes:
>Should a future language make a distinction between italics
>and boldface?  Between small and large character size?

I don't know if we'll have to address this issue soon, but the answer
should be obvious.  Should "Soviet Union", "USSR", and "CCCP" be treated
as the same identifier?  The simplest rule is, if it's expressed
differently, it IS different.

trent@unix.SRI.COM (Ray Trent) (04/29/89)

In the above article, jskuskin@eleazar.dartmouth.edu (Jeffrey Kuskin) writes:
>What I *DID* mean is:  "Why does the C language specify that keywords,
>identifiers, etc. be distinguished by case as well as by spelling."
>
>A quick example will clarify:
>
>In Pascal (a case-insensitive language by my definition), "myVar := 2"
>is the same as "mYvAR := 2"

And anyone who coded both of these statements in one file (or universe
for that matter) should be taken out immediately and shot (unless you
care to take the time to properly torture them before execution).

Listen and understand: if two objects are the same, they should appear
superficially the same, this is called "writing readable code". One way
of preventing idiots from using both "mYvAR" and "MyVar" in the same
program is to make the language case sensitive. Admittedly, this is
less of a problem when comparing "MYVAR" to "myvar" and "Myvar", but
what a kludge it would take to allow the latter and not the former.

Eris help us (by leaving us alone, please).-- 
"When you're down, it's a long way up
 When you're up, it's a long way down
 It's all the same thing
 And it's no new tale to tell"                      ../ray\..

gharris@secola.Columbia.NCR.COM (Buddy Harris) (05/01/89)

In article <30009@sri-unix.SRI.COM> trent@unix.sri.com (Ray Trent) writes:
>In the above article, jskuskin@eleazar.dartmouth.edu (Jeffrey Kuskin) writes:

>>In Pascal (a case-insensitive language by my definition), "myVar := 2"
>>is the same as "mYvAR := 2"
>
>One way
>of preventing idiots from using both "mYvAR" and "MyVar" in the same
>program is to make the language case sensitive. 

But shouldn't someone who is making the case for case-sensitivity double-check
the cases that they are writing in.  This shows how easy it is to accidentally
mess up a case that could take days to find depending upon your compiler.  And 
if you want types, variable, pointers, functions, etc. to have similiar names,
try a convention like tname, vname, pname, fname, etcname.  I will live with 
the C (or is it c) case-sensitivity, but I don't have to like it.  





-- 
------------------------------------------------------------------------------
! Sleep well and dream of large women.  -  The Dread Pirate Roberds          ! 
! gharris@secola.Columbia.NCR.COM (George Harris)  Have a nice day :-)       !
------------------------------------------------------------------------------

seanf@sco.COM (Sean Fagan) (05/02/89)

In article <59@ajfcal.UUCP> tony@ajfcal.UUCP (Tony Field) writes:
>In article <39708@think.UUCP>, barmar@think.COM (Barry Margolin) writes:
>> And the reason Unix is case-sensitive is that it was modeled after
>> Multics, which is also case-sensitive.  I suspect that the reason
>> Multics was made case-sensitive was that it seemed more modern.
>      .. etc ..

Another reason (or advantage) in Unix's case-sensitivity is that filenames
can have any character other than '/' and '\0'.  Every OS I've seen that had
case-*in*sensitivity would only allow a small subset of those.

Of course, you generally can't have a variable, in C, called 'M-fooM-bar'
(where M-<x> is Meta-<x>)... 8-)


-- 
Sean Eric Fagan  | "An acid is like a woman:  a good one will eat
seanf@sco.UUCP   |  through your pants." -- Mel Gibson, Saturday Night Live
(408) 458-1422   | Any opinions expressed are my own, not my employers'.