|
|
|
|
|
by burfog
2555 days ago
|
|
There are different notions of what an array is. In some languages, an array is dynamic. You don't have to declare the size. You can just put stuff at any index you desire, and the array will grow as needed. For example, just set foo[1000000000] to 42. That might take a gigabyte or more of RAM, or just address space, or neither. The indexes might not be required to be numbers. Some languages allow strings or even arbitrary objects as indexes. You could index by a JPEG or a device handle or a float. The values might not be required to have a consistent type. Some languages would let you throw random different-sized things into an array. |
|
Doesn't really matter for the general concept.
* The indexes might not be required to be numbers.
In most of those languages, that data type is called a map, dictionary, or even associative array. I've seen few languages actually use the phrase "associative array" primarily because it is confusing.
But, to be clear, I'm talking about the common "array" definition. That is, a value indexed by a number.
* The values might not be required to have a consistent type.
Yet, I was clear in saying "a byte array". A pointer points to the byte address and doesn't care about what type is ultimately represented. That is why void pointers are a thing. It is a language level action to reinterpret the pointer into a concrete object type.
But again, that confuses the issue of what pointers are with concerns like memory layout and object sizes. To be clear, you don't need to those concepts to understand what a pointer is.
* Some languages would let you throw random different-sized things into an array.
I specifically said "array of bytes". It does not matter what a language lets you do. A pointer is the head of a byte address and the interpretation of that byte and subsequent bytes are a language level concern. All unneeded information for a discussion on "what is a pointer".