www.digitalmars.com         C & C++   DMDScript  

D - Can we discuss case-sensitivity?

reply "Richard Krehbiel" <rich kastle.com> writes:
D is case-sensitive because C is, right?  Is that a good enough reason?

I've read a few flame-fests on comp.lang.c that, um, "discussed" this issue,
and I've never seen any authoritative word stating why case-sensitivity is
better - and I have my own catalog of personal experiences saying why it's
worse.

Why can't D be case-insensitive?

--
Richard Krehbiel, Arlington, VA, USA
rich kastle.com (work) or krehbiel3 comcast.net  (personal)
Feb 25 2002
next sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Richard Krehbiel wrote:

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this issue,
 and I've never seen any authoritative word stating why case-sensitivity is
 better - and I have my own catalog of personal experiences saying why it's
 worse.

 Why can't D be case-insensitive?

I would argue in favor of case senisitivity. However, I do not do so because I want to have multiple variables with different case patterns. Instead, I think that case sensitivity is a useful feature that helps enforce coding conventions. IMHO, code were the case patterns are consistent throughout improves readability. Allowing case INsensitivity would make it easier for programmers to (accidentally or intentionally) mix up case patterns. -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Feb 25 2002
parent "Richard Krehbiel" <rich kastle.com> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3C7A73A5.C4051D10 deming-os.org...
 Richard Krehbiel wrote:

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this


 and I've never seen any authoritative word stating why case-sensitivity


 better - and I have my own catalog of personal experiences saying why


 worse.

 Why can't D be case-insensitive?

I would argue in favor of case senisitivity. However, I do not do so because I want to have multiple variables with

 case patterns.

I don't think case-sensitivity gives you anything else.
 Instead, I think that case sensitivity is a useful feature that
 helps enforce coding conventions.  IMHO, code were the case patterns are
 consistent throughout improves readability.  Allowing case INsensitivity

 make it easier for programmers to (accidentally or intentionally) mix up

 patterns.

I'm thinking (perhaps wrongly) that you mean case-sensitivity enforces coding conventions that specify how to compose identifiers and in which case; for example, the Java conventions that say, type names begin with uppercase like ClassName, methods begin with lower case like methodName. Now, I immediately see an issue with that convention, specifically that you only have a single bit to distinguish two types of pattern. What if you need four, or six different patterns? You have to add some other identifiers. An associate of mine likes to tack the variable's scope onto identifiers; "l_var" is a local var, "i_var" is an instance var, "g_var" is global, "a_var" is a function argument, etc. He does this so he knows where to look for the object's definition. It's a powerful convention for his language (Powerbuilder; I don't need it because I can right-click and say "go to definition" in Visual C). Indeed, a case-sensitive language needs identifier case conventions, but if you didn't have a case-sensitive language, you'd use conventions such that identifier case doesn't matter. BTW, A case-insensitive language can *support* any such shop conventions as well, it just doesn't enforce them; and, before thinking how bad this is, I've seen coding-conventions documents that make rules for indentation and whitespace, even though few compilers have any means to enforce these. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)
Feb 25 2002
prev sibling next sibling parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Richard Krehbiel" <rich kastle.com> wrote in message
news:a5druk$1nic$1 digitaldaemon.com...

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this

 and I've never seen any authoritative word stating why case-sensitivity is
 better - and I have my own catalog of personal experiences saying why it's
 worse.

 Why can't D be case-insensitive?

Why not? =) Actually, I know only one argument for case-sensitivity: this way, you may be sure that everybody spells that function (class, enum, variable...) name the same. This is not so in Pascal, where for example most people call types Integer, Boolean, Char etc, while others (me) prefer integer, boolean, char - and others might think that using INTEGER is a good idea. Such a code can be damn hard to read.
Feb 25 2002
parent reply "Sean L. Palmer" <spalmer iname.com> writes:
In C I dislike using the C standard library functions (even C++ STL stuff
annoys me) since it doesn't use my preferred capitalization style, which
coincidentally is the same as Java uses.  (I don't use Java)

I just don't see why case is such a big deal, I'd really prefer that case
not matter at all.  If someone writes INTEGER all over I can always
global-search-and-replace that crap.  The *only* reason I can think of is it
allows the symbol lookups in the compiler to be a teeny bit faster, Pascal
parsers are a bit more complicated due to this case insensitivity.

Sean

"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5dt5k$1o4u$1 digitaldaemon.com...
 "Richard Krehbiel" <rich kastle.com> wrote in message
 news:a5druk$1nic$1 digitaldaemon.com...

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this

 and I've never seen any authoritative word stating why case-sensitivity


 better - and I have my own catalog of personal experiences saying why


 worse.

 Why can't D be case-insensitive?

Why not? =) Actually, I know only one argument for case-sensitivity: this way, you may be sure that everybody spells that function (class, enum, variable...) name the same. This is not so in Pascal, where for example most people call types Integer, Boolean, Char etc, while others (me) prefer integer, boolean, char - and others might think that using INTEGER is a good idea. Such a code can be damn hard to read.

Feb 25 2002
parent reply "OddesE" <OddesE_XYZ hotmail.com> writes:
"Sean L. Palmer" <spalmer iname.com> wrote in message
news:a5e1a2$1q52$1 digitaldaemon.com...
 In C I dislike using the C standard library functions (even C++ STL stuff
 annoys me) since it doesn't use my preferred capitalization style, which
 coincidentally is the same as Java uses.  (I don't use Java)

 I just don't see why case is such a big deal, I'd really prefer that case
 not matter at all.  If someone writes INTEGER all over I can always
 global-search-and-replace that crap.  The *only* reason I can think of is

 allows the symbol lookups in the compiler to be a teeny bit faster, Pascal
 parsers are a bit more complicated due to this case insensitivity.

 Sean

Yes, I agree. Basically, case sensitivity will enforce always writing the same identifier the same way (probably A Good Thing). However, it makes it impossible to write consistent code when using functions from different programmers that used different conventions for the use of case, as in the standard C libraries and the Win32 API: printf(), CreateWindowEx(), (probably A Bad Thing). Seems we have a tie... -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Feb 26 2002
parent reply Karl Bochert <kbochert ix.netcom.com> writes:
 
 Yes, I agree.
 Basically, case sensitivity will enforce always writing the same
 identifier the same way (probably A Good Thing). However, it
 makes it impossible to write consistent code when using functions
 from different programmers that used different conventions for
 the use of case, as in the standard C libraries and the Win32
 API: printf(), CreateWindowEx(), (probably A Bad Thing).
 Seems we have a tie...
 

capitalization styles to be a good thing. It serves to tag the code with the authors identity. I often intentionally use a differing style for the same reason. Karl
Feb 27 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Karl Bochert" <kbochert ix.netcom.com> wrote in message
news:1103_1014830062 bose...

 When maintaining complex code I have often found different
 capitalization styles to be a good thing. It serves to tag the code
 with the authors identity. I often intentionally use a differing style
 for the same reason.

I've always thought there are comments specially for that =)
Feb 27 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5jae1$166p$1 digitaldaemon.com...
 I've always thought there are comments specially for that =)

Comments? What are those?
Feb 27 2002
next sibling parent "Pavel Minayev" <evilone omen.ru> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a5kscb$1qri$1 digitaldaemon.com...

 "Pavel Minayev" <evilone omen.ru> wrote in message
 news:a5jae1$166p$1 digitaldaemon.com...
 I've always thought there are comments specially for that =)

Comments? What are those?

// You might have forgotten that "<g>"? =)
Feb 28 2002
prev sibling parent reply "OddesE" <OddesE_XYZ hotmail.com> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a5kscb$1qri$1 digitaldaemon.com...
 "Pavel Minayev" <evilone omen.ru> wrote in message
 news:a5jae1$166p$1 digitaldaemon.com...
 I've always thought there are comments specially for that =)

Comments? What are those?

:) I might 'label' my functions too: ODDPrint(); ODDOpenTable(); ODDAnotherFunc() OpenGL uses something like it: glBegin(); gluLookAt(); glutBlahBlah(); where glu and glut are libraries that extend OpenGL. I don't like it though.... -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Feb 28 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"OddesE" <OddesE_XYZ hotmail.com> wrote in message
news:a5lnc5$26sv$1 digitaldaemon.com...

 I might 'label' my functions too:

 ODDPrint();
 ODDOpenTable();
 ODDAnotherFunc()

 OpenGL uses something like it:

 glBegin();
 gluLookAt();
 glutBlahBlah();

 where glu and glut are libraries that extend OpenGL.

 I don't like it though....

"Labeling" is used to avoid name clashes - which no longer happens since D has modules.
Feb 28 2002
parent "OddesE" <OddesE_XYZ hotmail.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5loj7$27hp$1 digitaldaemon.com...
 "OddesE" <OddesE_XYZ hotmail.com> wrote in message
 news:a5lnc5$26sv$1 digitaldaemon.com...

 I might 'label' my functions too:

 ODDPrint();
 ODDOpenTable();
 ODDAnotherFunc()

 OpenGL uses something like it:

 glBegin();
 gluLookAt();
 glutBlahBlah();

 where glu and glut are libraries that extend OpenGL.

 I don't like it though....

"Labeling" is used to avoid name clashes - which no longer happens since D has modules.

Ah yes ofcourse, I hadn't thought of that...So that is why they did that! Microsoft didn't bother though...Luckily for us: MSCreateWindowEx(); MSMessageBox(); Imagine that? I really get annoyed of all the MS's now, also in their filenames... -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Feb 28 2002
prev sibling next sibling parent "OddesE" <OddesE_XYZ hotmail.com> writes:
"Richard Krehbiel" <rich kastle.com> wrote in message
news:a5druk$1nic$1 digitaldaemon.com...
 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this

 and I've never seen any authoritative word stating why case-sensitivity is
 better - and I have my own catalog of personal experiences saying why it's
 worse.

 Why can't D be case-insensitive?

 --
 Richard Krehbiel, Arlington, VA, USA
 rich kastle.com (work) or krehbiel3 comcast.net  (personal)

Interesting issue indeed... Here are some arguments, pre as well as con, about case sensitivity: Case sensitive code is A Good Thing: 1) Because it will avoid inconsistincies in code when one programmer writes printf, while another writes Printf. 2) Because it allows for two identifiers with names that differ only in case, like a constant or type and a variable. HANDLE handle; 3) Because it requires one less compilation step, hence making it faster to compile. Case sensitive code is A Bad Thing: 1) Because it will force inconsistincies in code written by the same programmer, when different other programmers chose different uses of case for libraries: printf, CreateWindowEx 2) Because it allows for two identifiers with names that differ only in case, like a constant or type and a variable. HANDLE handle; 3) Because to humans, words don't significantly change their meaning, just because their case does. They might to programmers though... :) Interestingly enough argument 2) can be used to attack as well as support case sensitivity. In the end I think it comes down to personal taste. Both methods have their merits. Since a lot of D code has already been written that might be dependant of case sensitivity, I think changing it is not worth the effort. Purely looking at it from a conceptual point of view though, I support case insensitive code, like Pascal. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Feb 25 2002
prev sibling next sibling parent reply Karl Bochert <kbochert ix.netcom.com> writes:
On Mon, 25 Feb 2002 12:23:08 -0500, "Richard Krehbiel" <rich kastle.com> wrote:
 D is case-sensitive because C is, right?  Is that a good enough reason?
 
 I've read a few flame-fests on comp.lang.c that, um, "discussed" this issue,
 and I've never seen any authoritative word stating why case-sensitivity is
 better - and I have my own catalog of personal experiences saying why it's
 worse.
 
 Why can't D be case-insensitive?
 

Letter case is not significant in our notation, as it is too dangerous to let two almost identical identifiers denote different things." Me: Letter case is significant in my notation, as it is too dangerous to let two different identifiers denote the same thing. Case-uniqueness is a third possibility: Case is significant, but identifiers can not be distinguished by case alone. Having defined 'Foo', the definition or use of 'foo' would be prohibited. Karl Bochert
Feb 25 2002
next sibling parent reply Russell Borogove <kaleja estarcion.com> writes:
Karl Bochert wrote:
 Case-uniqueness is a third possibility: Case is significant, but identifiers
 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.
 

I could accept that, and would prefer it to case-insensitivity. It would lead to writing things like: HANDLE handle_; or HANDLE myHandle; where one might want to write HANDLE handle; -RB
Feb 25 2002
next sibling parent reply Barry Pederson <bp barryp.org> writes:
Russell Borogove wrote:
 Karl Bochert wrote:
 
 Case-uniqueness is a third possibility: Case is significant, but 
 identifiers
 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.

I could accept that, and would prefer it to case-insensitivity. It would lead to writing things like: HANDLE handle_; or HANDLE myHandle; where one might want to write HANDLE handle;

I like that idea! I've always hated case-sensitivity because of the way people abuse it with things like "Handle handle;", but have never minded being forced to use consistent capitalization myself (I think it's good to have at least certain amount of discipline when writing code) This would give you the best of both worlds, ruling out both kinds of laziness: using confusing names, and just plain sloppy writing. Barry
Feb 25 2002
parent "Richard Krehbiel" <rich kastle.com> writes:
"Barry Pederson" <bp barryp.org> wrote in message
news:3C7B0559.8060205 barryp.org...
 Russell Borogove wrote:
 Karl Bochert wrote:

 Case-uniqueness is a third possibility: Case is significant, but
 identifiers
 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.

I could accept that, and would prefer it to case-insensitivity. It would lead to writing things like: HANDLE handle_; or HANDLE myHandle; where one might want to write HANDLE handle;

I like that idea! I've always hated case-sensitivity because of the way people abuse it with things like "Handle handle;", but have never minded

 forced to use consistent capitalization myself (I think it's good to have

 least certain amount of discipline when writing code)

 This would give you the best of both worlds, ruling out both kinds of
 laziness: using confusing names, and just plain sloppy writing.

Well... I suppose if D were this way, then a smart editor could correct the case of any identifier the user types in, since it's known to be distinct (rather like Visual Basic does). And, I could write a preprocessor that would fix the case of each identifier prior to compilation. Sheesh. I though programming languages were supposed to make coding easier. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)
Feb 26 2002
prev sibling parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
<cheer>  Good idea!

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]
Feb 26 2002
prev sibling parent reply "Richard Krehbiel" <krehbiel3 comcast.net> writes:
"Karl Bochert" <kbochert ix.netcom.com> wrote in message
news:1103_1014692646 bose...
 On Mon, 25 Feb 2002 12:23:08 -0500, "Richard Krehbiel" <rich kastle.com>

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this


 and I've never seen any authoritative word stating why case-sensitivity


 better - and I have my own catalog of personal experiences saying why


 worse.

 Why can't D be case-insensitive?

Letter case is not significant in our notation, as it is too dangerous to

 two almost identical identifiers denote different things."

 Me:
 Letter case is significant in my notation, as it is too dangerous to let
 two different identifiers denote the same thing.

Um - I'm having trouble making sense of that. It looks like you just spoke out against type aliases (two different names for the same thing).
 Case-uniqueness is a third possibility: Case is significant, but

 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.

Um - okay, now I'm further puzzled. After having defined "Foo", attempting to define "foo" is the same as attempting to redefine "Foo". What makes this different from case-insensitivity?
Feb 26 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Richard Krehbiel" <krehbiel3 comcast.net> wrote in message
news:a5fmn2$2iod$1 digitaldaemon.com...

 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.

Um - okay, now I'm further puzzled. After having defined "Foo",

 to define "foo" is the same as attempting to redefine "Foo".  What makes
 this different from case-insensitivity?

It differs in that you cannot write "foo", or "FOO", but only "Foo" - as it's spelled by the one who'd declared it.
Feb 26 2002
parent "Richard Krehbiel" <rich kastle.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5fs1m$2kur$1 digitaldaemon.com...
 "Richard Krehbiel" <krehbiel3 comcast.net> wrote in message
 news:a5fmn2$2iod$1 digitaldaemon.com...

 can not be distinguished by case alone.  Having defined 'Foo',  the
 definition or use of 'foo' would be prohibited.

Um - okay, now I'm further puzzled. After having defined "Foo",

 to define "foo" is the same as attempting to redefine "Foo".  What makes
 this different from case-insensitivity?

It differs in that you cannot write "foo", or "FOO", but only "Foo" - as it's spelled by the one who'd declared it.

Oh, I get it now. Case sensitivity with an attitude. I personally think that's going the wrong direction. The need for case-*in*sensitivity includes my being able to spell an identifier without being able to remember exactly how the capitalization works. For example, here's the trouble I have with MixedCase identifiers, where each "component" of the identifier is capitalized. I can figure out the proper capitalization of English words. But what about acronyms? Proper English (apparently) says acronyms are spelled in CAPS, as in "SQL" and not "Sql". But since the "SQL" in "SQLExecute" is a component word, should it be "SqlExecute", to conform to capitalization conventions? And then, I also offer into evidence the function "SQLNativeSql" (and BTW these are real examples from Microsoft's ODBC API) which by itself uses *both* conventions. As much as I'd like to say "shoot these API designers and fix the conventions," this was Microsoft and they're not going to be responsive. So I say, the language can save us from this madness and ignore the identifier case. PS: My C coding conventions prohibit any capitals in identifiers, except some #defines and enumeration constants which are UPPER CASE - and yet, there are plenty of #defines which have function-like behavior and are therefore lower case. Sigh. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 comcast.net (personal)
Feb 26 2002
prev sibling parent reply Roland <rv ronetech.com> writes:
Richard Krehbiel a écrit :

 D is case-sensitive because C is, right?  Is that a good enough reason?

 I've read a few flame-fests on comp.lang.c that, um, "discussed" this issue,
 and I've never seen any authoritative word stating why case-sensitivity is
 better - and I have my own catalog of personal experiences saying why it's
 worse.

 Why can't D be case-insensitive?

One of the bigger bug i ever had: class Arc: public Something { //note the case of Arc . virtual int id()const { return A_VALUE; } . }; somewhere else, written by somebody else, in an other library: class ARC: public SomethingElse { //note the case of ARC . virtual int id()const { return AN_OTHER_VALUE; } . }; Unfortunately the linker or the librarian was not configured to be case sensitive. So the linker took the first one it found and throw away the other one. You can guess the problem.. To avoid that, the compiler, the linker and the librarian _must_ _all_ be case sensitive. In that case, one of the 3 would have complained. More generaly: I think name convention is important. Microsoft know that when they almost force there developpers to use ugrarian convention. Too much i think in a strong typed langage like C. HP developpers didn't care at all when they created STL: STL type names are really names i could have used (and used) for local data names. At the beginning of D, i hesitateted to send a post sugesting that D _force_ name standardization. Here what i was about to suggest: - arguments or local data name: should start with a isalpha letter (not underscore) and be _all_ low case, - data/function name: the first isalpha letter should be low case, - #defines: _all_ isalpha letters should be UPPER case, - Type names: first isalpha letter should be UPPER case next cannot be forced by the compiler (waiting for compiler using AI): - the more the name is global (#defines, Type name, global data/function name), the longuer and explicit it should be, - at the contrary, statics function/data, local data or arguments names can be very short, - leading underscore: generaly, exept for local data or arguments name, underscore indicates the 'depth in privacy' of the name, that mean if it is here for the "user" (the one who will use what you implemented), or just to help implementation. In that case, the name should begin with at least one underscore. Having a case sensitive langage can help force standadization i think. roland
Mar 01 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Roland" <rv ronetech.com> wrote in message
news:3C7FC3AE.4AD224B ronetech.com...

 At the beginning of D, i hesitateted to send a post sugesting that D

 name standardization.
 Here what i was about to suggest:
 - arguments or local data name: should start with a isalpha letter (not
 underscore) and be _all_ low case,

I don't think it's a good idea to define some strict rules for locals. They're implementation detail, after all. Better focus on the interface.
 - data/function name: the first isalpha letter should be low case,
 - #defines: _all_ isalpha letters should be UPPER case,

You mean consts/enums? Then, I don't agree. Personally, I hate this C tradition of writing all constants in upper case. I prefer to name consts in the same way as variables, and capitalize first letter of each word of enum member. Anyhow, I don't think it's the best idea. Walter had specified a recommendation that most people will follow (I hope =)). But some companies prefer to develop their own schemas for internal use, why not let them do so?
Mar 01 2002
parent "Juan Carlos Arevalo Baeza" <jcab roningames.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5omjt$lkl$1 digitaldaemon.com...

 Anyhow, I don't think it's the best idea. Walter had specified
 a recommendation that most people will follow (I hope =)).
 But some companies prefer to develop their own schemas for
 internal use, why not let them do so?

Some languages use naming schemes to help with parsing, and to eliminate clutter from the language. Take Haskell, for example: - ident beginning with lowercase: functions and variables. - ident beginning with uppercase: types and type constructors - Symbols: operators - Symbols in parens: operators being used as functions It helps them remove the need for extra symbols (parenthesis and commas for parameters, for example). It is definitely not the C/C++ way, though. Salutaciones, JCAB
Mar 01 2002