swampdog wrote: ↑Wed Oct 14, 2020 8:32 pm
Well you say that.
Yes I say that.
Of course it all depends on what language you are talking about and how it defines pointers and arrays.
In C and C++ there is of course a very tight relationship between raw pointers and arrays and array elements.
That need on be so. For example:
I can imagine a language where A is an array and A[42] is an element of that array.
In my imaginary language I could allow that P is a pointer to that element. Perhaps created from P = &A[42]. One could use it to refer to that element, pass it to functions and threads and so on so that they can refer to that same element.
BUT, that does not imply that P + 1 is necessarily a pointer to the next element of the array A[43].
Why should it?
Perhaps I do not store arrays in such simple consecutive order in memory in my imaginary language.
What I'm getting at is that a low level concept like a memory address, a pointer, need not have any relation to a high level language concept like an array.
In fact, I don't need to imagine such a language. In the Rust language there are no pointers in normal use. In not so normal use, denoted with the "unsafe" keyword, you can get raw pointers to values and objects and array elements. But ideas like P + 1 are undefined behavior.
Memory in C++ is a leaky abstraction .