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,bd45e29f9dafca87 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: bitwise comparators Date: 2000/01/19 Message-ID: #1/1 X-Deja-AN: 574886773 Sender: kst@king.cts.com References: <3880D375.7E363123@hotmail.com> <38829638.0@news.pacifier.com> <3882FC1C.2BA8C959@hotmail.com> <85vmn2$ki1$1@nnrp1.deja.com> <38836CF2.AB738B8B@hotmail.com> <3883A414.8559E641@earthlink.net> <3885EAA7.FAF93A78@earthlink.net> X-Trace: thoth.cts.com 948321279 67833 198.68.168.21 (19 Jan 2000 22:34:39 GMT) Organization: CTS Network Services Newsgroups: comp.lang.ada X-Complaints-To: newsmaster@cts.com Date: 2000-01-19T00:00:00+00:00 List-Id: Jeff Carter writes: > Keith Thompson wrote: > > Jeff Carter writes: > > [...] > > > C does not have arrays; it only has different notations for address > > > arithmetic. > > > > That's a slight exaggeration. C does have array types and array > > objects. For example this: > > int a[10]; > > declares a as an array of 10 ints, very much like Ada's > > A: array(0 .. 9) of Integer; > > It does not, contrary to popular misconception, declare a as a > > pointer. > > That would explain why a[0] and *a are different notations for the same > thing, and a[2], *(a+2), and 2[a] are also different notations for the > same thing. a[2] is defined as a shortcut for *(a+2), which is why 2[a] > works. The "array" notation in C is a different notation for address > arithmetic. I stand by my statement. C does have arrays; it just defines some of the operations on arrays in terms of lower-level operations, exposing some of the nuts and bolts that Ada (wisely, IMHO) hides. For example, "&a" yields the address of a, and is of type "pointer of array of 10 ints", not "pointer to int". Similarly, "sizeof a" yields the size of the array, not the size of a pointer. If a structure member is an array, the full space for the array is allocated in each object of the structure type, and the structure can be assigned and passed by copy. C arrays are *partly* built on the lower-level concept of pointers, but not entirely. Section 6 of the C FAQ, at , explains this better than I can. > Meanwhile, in Ada, A (0) and A (2) are legal, but A.all, 2 (A), and (A + > 2).all give compiler errors. Which means that Ada arrays are closer to being first-class types than C arrays are. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Welcome to the last year of the 20th century.