Hello FPC-Pascal,

Tuesday, May 4, 2010, 9:41:27 PM, you wrote:

M> I have never found anything that says, that an array (not a
M> static-array, just an array), always and under any circumstances must
M> ensure that the identifier of the whole array is equal to the first
M> data-element in the array?
M> I don't even think there is a guarantee that all the data elements are
M> found at consecutive addresses in memory. (which is also required in
M> order to use move)

The problem is a bunch of literature that many people encumber but are
wrong in definition. Some definitions are fine, like the wikipedia
one:

"In computer science, an array data structure or simply array is a
data structure consisting of a collection of elements (values or
variables), each identified by one or more integer indices, stored so
that the address of each element can be computed from its index tuple
by a simple mathematical formula."

And of course the "pascal gurus" that shows us that to copy an array
(static) the proper way is
"move(array1,array2,elements*sizeof(element))" when as far as I know
the result of this operation is undefined but luckily works in most
architectures. Much better would be "move
(array1[0],array2[0],elements*sizeof(element))" but even in this case
the result is undefined, but it is a bit more exact as the programmer
is not assuming that the array pointer is the same address as the
first element.

So nobody can copy an array accessing its identifier, but at least
accessing the first element, assuming that data is contiguous.

-- 
Best regards,
 José

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to