Array notation is nothing but syntactic sugar. It's a base address +
an offset into a block of uniformly sized memory blocks. Nothing in
the language absolves you of the responsibility to stay in the bounds
of what the compiler allocates for the array on the stack, or you
explicitly allocate in the heap.
My bet is that Will was a CS major. This is the kind of trivia that
makes a good quiz question in a lower division "programming" class.
But, as we now have operating systems that keep programmer mistakes
with this stuff from hurting the whole system, having a real
understanding of what's going on is probably a waste of most
developer's time.
-Brad
On Sep 30, 2005, at 10:37 AM, Will Leshner wrote:
Ok, again this is for the benefit of our listeners, but (and this
is more a general C thing than anything specific to C++) pointers
and arrays are really just two ways to say the same thing in C. In
fact, I'd go so far as to say that array notation is just syntactic
sugar for pointers. I would expect that most compilers would
generate the same code for both.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|