bengsig@oracle.nl (Bjorn Engsig) (04/26/89)
In article <1314@ns.network.com> ddb@ns.UUCP (David Dyer-Bennet) writes: > >How DO people feel about identifiers differing only in casing? Is this >ok? To be COMPLETELY avoided? To be avoided except in a very few >well-understood conventional cases? > One of the more common cases where you use identifiers only different in case is for union fields inside structures, e.g.: struct abc { int a, b, c; union { char Array[4]; long Whole; } wa_union; }; #define array wa_union.Array #define whole wa_union.Whole which allows you to rerefence the union fields in your program without having to supply the union name, i.e. abcvar.array[2] in stead of abcvar.wa_union.Array[2]. -- Bjorn Engsig, ORACLE Europe \ / "Hofstadter's Law: It always takes Path: mcvax!orcenl!bengsig X longer than you expect, even if you Domain: bengsig@oracle.nl / \ take into account Hofstadter's Law"
ddb@ns.network.com (David Dyer-Bennet) (04/28/89)
In article <318.nlhp3@oracle.nl> bengsig@oracle.nl (Bjorn Engsig) writes: :In article <1314@ns.network.com> ddb@ns.UUCP (David Dyer-Bennet) writes: :> :>How DO people feel about identifiers differing only in casing? Is this :>ok? To be COMPLETELY avoided? To be avoided except in a very few :>well-understood conventional cases? :> :One of the more common cases where you use identifiers only different in case :is for union fields inside structures, e.g.: : :#define array wa_union.Array :#define whole wa_union.Whole And the other pretty-common case I'm aware of is typedef struct FOOBAR { int e1, e2, e3; struct FOOBAR *next; } foobar; (people often disagree on exactly the casing for each use). Are there any other standard idioms for case-distinguished related names? (Nobody much seems to be addressing what I view as a substantive question raised in passing in the flamefest, namely when is it "good programming practice" to use identifiers differing only in casing in C. I feel the cases described above are "commonly accepted" instances, and guess that most people feel that the practice should be avoided except in particular special cases like these. Some people may feel that "accidental" collisions are fine, but would avoid "systematic" ones. It seems to me that this question must necessarily be answered before the question of case sensitivity in the language can be thoroughly debated, because many people might favor certain uses, and oppose others.) (And I've seen a few people suggesting using casing for emphasis in some cases (with no examples from practice), but no other suggestions that identifiers should be cased differently at different times. We DO seem to mostly agree on a few things...) -- David Dyer-Bennet, ddb@terrabit.fidonet.org, or ddb@ns.network.com or ddb@Lynx.MN.Org, ...{amdahl,hpda}!bungia!viper!ddb or ...!{rutgers!dayton | amdahl!ems | uunet!rosevax}!umn-cs!ns!ddb or Fidonet 1:282/341.0, (612) 721-8967 9600hst/2400/1200/300