From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2078dddcdcd8d83 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Warning: Religious naming convention discussion :-) [was: assign help!!] Date: 1997/05/13 Message-ID: #1/1 X-Deja-AN: 241286950 References: <5kjvcv$evt@news.cis.nctu.edu.tw> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-05-13T00:00:00+00:00 List-Id: In article , Robert Dewar wrote: >Why are C arrays very low-level notions? Because: 1. They don't carry their length (or bounds) with them. You have to pass this information "by hand", as a separate thing. 2. There are no "whole array" operations, such as assignment and comparison. (Yes, there are library functions for these, but they don't operate on whole arrays -- they take pointer-to-first-element and size/length parameters separately.) 3. You can't pass an array as a parameter -- you have to pass a pointer to the first component, instead. (Or, looking at it a different way, an array *is* a pointer to the components. C is pretty confused on this point.) And having done that, there's no way to tell, in the language, whether a given formal parameter of type t* is pointing to a t, or to the first element of an array of t's. 4. Array indexing is defined in terms of pointer arithmetic. (Well, I admit this is a rather weak reason.) 5. The lower bound is always zero, rather than whatever makes sense to the programmer. E.g. if you want a table that maps the numbers A..B onto something-or-other, you have to subtract off A "by hand" All of the above give me the feeling that a C array is, conceptually, a pointer to a hunk of contiguous storage. That's a low-level, machine-oriented, notion. >I agree they are often used this way, but I don't see this from the standard. - Bob