Peter N Lewis wrote:
On the subject of range checking, another difference that Mac Pascals implemented was unrangechecked arrays where the lower and upper bound are both 0.
That is:
stupid because
type UnboundArray = array[0..0] of Whatever;
is a perfectly valid Pascal array of size 1.
disables the range check tests for array access.
which is wrong if one actually declares a variable of this type (which the compiler doesn't prevent, I assume?). I know this kludge from BP (though one has to disable range-checking explicitly). I prefer the following kludge: type UnboundArray = array [1 .. MaxVarSize div SizeOf (Whatever)] of Whatever; This "disables" range-checking for this type by making the range as big as possible. It also should prevent declaring a variable of this type for size reasons. The kludge also works in GPC, BTW, and might in Mac Pascals (with a suitable definition of MaxVarSize, of course).
Generally this is used for open arrays as parameters, and it pretty much just avoids having to define a specific maximum array size (which can also get in to trouble, such as:
type UnboundArray = array[0..kMaxInt] of Whatever;
which can have a size bigger than 4Gig if Whatever has any noticeable size, and which can cause problems (does GPC handle record/array sizes larger than 32 bits on 32 bit platforms?).
No (therefore the `div' above, same in BP with MaxVarSize = $fff0). Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707