Pointer array: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>Marshall
mNo edit summary
m (2 revisions imported: Migrate from miraheze)
(No difference)

Revision as of 14:48, 20 November 2019

In nested array theory, a pointer array is an array which is mixed or nested. It corresponds to an array of boxes in flat array theory: pointer arrays are exactly those which require boxes to store in a flat APL. Every array is either a simple character, simple numeric, or pointer array (adding a new class of simple scalar would add a new possibility).

Pointer arrays take more space to store than flat arrays and are often slower to manipulate. The size of each pointer is the processor's machine word size—64 bits on a 64-bit machine. However, each element of a pointer array is itself an array, and is stored with an array header which may be several times the size of a pointer. When a simple array is converted to a pointer array, for instance, by appending a non-simple array as an element, the space used may be tens or even hundreds of times larger than it was before. If the type of the original array elements was smaller (in bits) than a pointer, structural functions on the array will be slower. Even if the original type was large, functions that need to read elements of the array, such as scalar functions, will be many times slower because of the need to follow a pointer to read every element.