What is a consistent array?

I am trying to figure out what the corresponding array is, but I cannot find a good definition anywhere. Can someone explain what this is and give me a basic example and what is their purpose?

thanks

+6
source share
3 answers

So this is a really old question, but it appears early in the search results, so let me give you the correct answer.

A conformal array is not a dynamic array that resizes to fit data, such as the Java List class. This is a mechanism that allows Pascal procedures and functions to work with variable size arrays.

In Pascal, the size of the array is part of its type, so in:

VAR MyArray1 : ARRAY [1..10] OF INTEGER; MyArray2 : ARRAY [1..20] OF INTEGER; 

MyArray1 and MyArray2 have two different types and are incompatible.

This becomes a problem with procedures / functions in the classic Pascal: since the formal parameters of a procedure must be of a certain type, and since the length of the array is part of its type, it is generally impossible to define a procedure / function that works on arrays of arbitrary length.

Conformal arrays were introduced as part of the ISO Pascal standard to solve this problem, allowing the definition of a procedure / function using a "consistent array" as a parameter:

 PROCEDURE MyProc(VAR x : ARRAY [low..high : INTEGER] OF INTEGER; 

This defines the procedure MyProc with three formal parameters: x , low and high (i.e. three parameters are passed in an arbitrary name). When the procedure is called, x set to a pointer to the array, low is an integer variable set to the bottom of the array, and high is an integer variable set to the top of the array.

This mechanism allows you to transfer the boundaries of an array with an array of a safe type and allows you to process procedures with arrays of arbitrary size. This is a function defined by ISO Standard Pascal, but other Pascals (e.g. Extended Pascal and Borland Pascal) have developed various mechanisms to solve this problem (e.g., extended Pascal type circuits that are much richer and more complex).

+9
source

The corresponding array is one that is undefined and stretched or compressed to fit its data.

An example is List in Java.

A Google search will give you tons of results if you need more information.

+2
source

This is an even older question (now), but it was the first answer when I searched googled for "what matches an array". On Windows, in terms of IDLs and languages ​​using IDLs (C and C ++), the definition is here .

Quote from an article: “An array is called“ consistent ”if the upper bound of any dimension is defined at run time. (Only the upper bounds can be defined at run time.)"

+1
source

Source: https://habr.com/ru/post/903639/


All Articles