J
James Kuyper
On 05/24/2013 08:23 AM, Malcolm McLean wrote:
....
Some have said that counting is just a more primitive aspect of
arithmetic than addition is, and I think their point of view makes at
least as much sense as yours, but that's not really the key point of
contention. The real issue is your insistence on associating array
subscripting with counting, and not with addition.
The former, in my opinion, though the latter could be another way of
thinking about it, if you consider 42 as simply a label rather than a
number. However, it is a valid way of thinking about it only to the
extent that it is NOT associated with counting. Interpreting "taking
item 42" in a way that connects it with counting loses all contact with
hardware reality, actual compiler implementations, and the descriptions
used in the C standard. It might be a suitable way of thinking about an
array stored in serial access memory, rather than RAM, but that is
hardly the conventional way of implementing C arrays.
Base+offset is addition, and therefore arithmetic, as I see it. In
contexts where an array has a fixed address, and is subscripted with a
compile-time constant, the compiler might generate instructions that
load the address directly into a suitable register, without performing
addition. However, that just means that the addition was performed at
compile time rather than run time - it's still addition. Either way, it
has nothing to do with counting, or at least it has nothing more to do
with counting than addition itself has to do with counting, and the
analogy is exact.
....
We need to establish that counting - knowing the names of the numbers and
the next one - isn't arithmetic. Which was disputed but now seems to have
been accepted (counting isn't "adding one").
Some have said that counting is just a more primitive aspect of
arithmetic than addition is, and I think their point of view makes at
least as much sense as yours, but that's not really the key point of
contention. The real issue is your insistence on associating array
subscripting with counting, and not with addition.
That accepted, is array[42] adding 42 to array, taking the result, and
dereferencing it, or going to the collection marked "array" and taking item
42?
The former, in my opinion, though the latter could be another way of
thinking about it, if you consider 42 as simply a label rather than a
number. However, it is a valid way of thinking about it only to the
extent that it is NOT associated with counting. Interpreting "taking
item 42" in a way that connects it with counting loses all contact with
hardware reality, actual compiler implementations, and the descriptions
used in the C standard. It might be a suitable way of thinking about an
array stored in serial access memory, rather than RAM, but that is
hardly the conventional way of implementing C arrays.
... Internally, somewhere, we're going to have to generate the address of
item 42 in the array, but at machine code level the address might well never
appear, it could just as easily be a base (probably not array) and an offset,
depending on the exact instruction set used.
Base+offset is addition, and therefore arithmetic, as I see it. In
contexts where an array has a fixed address, and is subscripted with a
compile-time constant, the compiler might generate instructions that
load the address directly into a suitable register, without performing
addition. However, that just means that the addition was performed at
compile time rather than run time - it's still addition. Either way, it
has nothing to do with counting, or at least it has nothing more to do
with counting than addition itself has to do with counting, and the
analogy is exact.