Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site dg_rtp.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!ittatc!dcdwest!sdcsvax!ncr-sd!ncrcae!ncsu!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: net.lang.c Subject: Re: Address of array Message-ID: <226@dg_rtp.UUCP> Date: Tue, 18-Mar-86 13:36:04 EST Article-I.D.: dg_rtp.226 Posted: Tue Mar 18 13:36:04 1986 Date-Received: Fri, 21-Mar-86 05:35:45 EST References: <1709@brl-smoke.ARPA> Lines: 61 > [...] C's treatment of array/function/struct addresses is > inconsistant, confusing, and limiting. > > I diagree violently (so what else is new?). The resolution of pointers > and arrays is one of the *strengths* of C. Actually, you disagree needlessly :-). I said that things were treated inconsistantly, not that array/pointer equivalence is a not-good idea. > Admittedly there are a few glitches, Ah, you've noticed that too, eh? > such as when the sizeof operator is applied to an array. Ironically, > this glitch was added to *help* the user. Glitches added to help the user are still glitches. And, in the end, I question whether they actually help the user. > Personally, when a formal > parameter is declared as a local array, I would like to see sizeof > return the same as if it was a global. You too? Good. You listening, ANSI? > In essence a small notational > convenience was traded for a large consistancy headache. I think the > tradeoff was wrong, [...] > > All the compilers I've seen give a warning, but generate &array[0]. Let me clarify what small notational convenience and what consistancy headache I am talking about here. The notational convenience is that an array name "means" the address of the first element of the array. The consistency headache is that then addressing (and "mentioning") of arrays and other things (such as structs) does not behave similarly, and it becomes impossible to (legally, formally) take the address of an entire array (at least, without adding warts to the warts and making yet another "glitch"). The idea of array/pointer equivalence would cause *much* fewer problems if the question of notational convenience of passing arrays (by reference) hadn't clouded the issue. This led directly to the common confusions about whether definitions of pointers reserve space for the items pointed to (and as to whether array declarations do, also), the confusion of whether a structure name indicates the address of the structure or it's contents, the inability to treat arrays by value (since you get a reference whenever the name of the array is mentioned), and so on and on. I am not arguing here from a "language purity" high horse. I am saying that actual experience with C and the type of errors that are commited in the use of C make me think that the treatment of array and function addressing (and the fact that these things are different from struct addressing) has spread confusion. Further, this confusion has made the C language much harder to master then it "ought" to be, and has obscured some of its strong points, such as array/pointer equivalence. -- Wayne Throop at Data General, RTP, NC !mcnc!rti-sel!dg_rtp!throopw