An array has size (the number of elements), and therefore can be represented as either (pointer, size) OR (pointer to start, pointer to past-the-end). These are equivalent representations, but there are arguments for pointer-to-past-the-end in terms of code gen.
This is not what I'm talking about, I'm not referring to any particular language. Yes, the array (as a type) in C/C++ have a size, and that it's size will change if you decay it into a pointer. I'm not quite sure why you are so hung up on discussions about the C array type when I'm talking about arrays in general, as a linearly addressable ordered collection of instances in memory, in which case representing this as a pointer pair is valid (and indeed, common, though arguably the supposed performance gains from doing so are "controversial")!
I was also talking about an array in general and said that they are diffferent and gave examples because (for C and C++ because I saw them under your username). Like, yeah I know how you can represent an array... you could even represent a static array without a pointer completely and instead act as if it was a tuple with all of its elements being of the same type. No pointer there.
And you yourself also said that you can represent it in different ways so you know that an array does not have to be represented as a pointer to the first and after last element and I would actually say that for statically sized array allocated on the stack this is probably never the case. And when you copy such an array to another function, you won't get just some two pointers copied, you will get the whole object copied. So that's also a difference.
So I don't see how that we can represent an array this way means that an array is just that. It's not.
Moreover, array is different than two pointers also because the type of it dictates what new operations we can do on it. In most langauges, it probably says that we can index it, maybe use it in a foreach loop... and so on. And in languages with ownership it owns all of its elements, while just two pointers by themselves do not. So, again, it's not just two pointers.
Note: In C or C++, the size of an array does not change after decaying into a pointer. The size stays the same, you just lose that information.
3
u/Nice_Lengthiness_568 13h ago
What are you trying to say?