comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: bitwise comparators
Date: 2000/01/19
Date: 2000-01-19T00:00:00+00:00	[thread overview]
Message-ID: <yecvh4pk7wh.fsf@king.cts.com> (raw)
In-Reply-To: 3885EAA7.FAF93A78@earthlink.net

Jeff Carter <jrcarter010@earthlink.net> writes:
> Keith Thompson wrote:
> > Jeff Carter <jrcarter010@earthlink.net> 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 <http://www.eskimo.com/~scs/C-faq/top.html>,
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  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.




  parent reply	other threads:[~2000-01-19  0:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-15  0:00 bitwise comparators Alexander Van Hecke
2000-01-15  0:00 ` David C. Hoos, Sr.
2000-01-16  0:00 ` Jeff Carter
2000-01-16  0:00 ` Bryce Bardin
2000-01-16  0:00 ` Matthew Heaney
2000-01-16  0:00 ` DuckE
2000-01-17  0:00   ` Alexander Van Hecke
2000-01-17  0:00     ` Jeff Carter
2000-01-17  0:00       ` Alexander Van Hecke
2000-01-17  0:00         ` David Starner
2000-01-17  0:00           ` Alexander Van Hecke
2000-01-17  0:00             ` David Starner
2000-01-18  0:00             ` Fraser
2000-01-18  0:00               ` Bertrand Augereau
2000-01-19  0:00                 ` Ted Dennison
2000-01-19  0:00                   ` Marin D. Condic
2000-01-19  0:00                     ` Ted Dennison
2000-01-18  0:00             ` Preben Randhol
2000-01-18  0:00           ` Ted Dennison
2000-01-17  0:00         ` Gautier
2000-01-17  0:00           ` Alexander Van Hecke
2000-01-17  0:00             ` David Starner
2000-01-18  0:00             ` Gautier
2000-01-18  0:00           ` Ted Dennison
2000-01-18  0:00         ` Jeff Carter
2000-01-18  0:00           ` Keith Thompson
2000-01-19  0:00             ` Jeff Carter
2000-01-19  0:00               ` David Starner
2000-01-19  0:00               ` Keith Thompson [this message]
2000-01-19  0:00             ` Ole-Hjalmar Kristensen
2000-01-19  0:00             ` Gisle S�lensminde
2000-01-18  0:00         ` Pascal Obry
2000-01-21  0:00         ` Ada vs. C/C++ (was re: bitwise something-or-other) Mark Lundquist
2000-01-21  0:00           ` Mark Lundquist
2000-01-24  0:00           ` Hyman Rosen
2000-01-17  0:00     ` bitwise comparators Gautier
2000-01-18  0:00       ` Keith Thompson
2000-01-19  0:00         ` Ole-Hjalmar Kristensen
2000-01-17  0:00     ` Matthew Heaney
2000-01-17  0:00     ` Mike Silva
2000-01-17  0:00       ` Alexander Van Hecke
2000-01-17  0:00         ` David Starner
2000-01-17  0:00         ` Gautier
2000-01-17  0:00         ` Mike Silva
2000-01-18  0:00           ` Charles Hixson
2000-01-17  0:00       ` Brian Rogoff
2000-02-05  0:00         ` Ashley Deas Eachus
2000-02-05  0:00           ` Jeff Carter
2000-02-06  0:00           ` Andy
2000-02-07  0:00           ` Brian Rogoff
2000-02-09  0:00             ` Robert Iredell Eachus
2000-01-17  0:00     ` tmoran
2000-01-17  0:00     ` David C. Hoos, Sr.
2000-01-18  0:00     ` DuckE
2000-01-18  0:00     ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox