On Wed, 30 Jul 2003, 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:
type UnboundArray = array[0..0] of Whatever;
disables the range check tests for array access.
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?).
Anyway, I don't know that this is worth emulating even with --mac-pascal turned on, but I figured I'd mention it while I thought of it and while range checks were being discussed.
(I'm sorry if this has been discussed in Dec/2002, I couldn't find in archives.)
Perhaps it's worth a spare attribute or two, such as
attribute(norange);
and
attribute(mustrange);
(the names are not obligatory part of suggestion).
They'd allow finer-grained range checking control than {R+} and {R-}, per object or per entity. Of course, if that's not too much trouble for Frank.
I hope it's not adding too much complexity to the compiler. In ideal case, every particular type of range check might be turned on/off independently. OTOH, you might consider it an overkill, as GNU Pascal is not used for programming Mars vehicles anyway (-;
I've read about some researches telling how most often errors are so called "of by one" errors, and IMHO is thus a vital part of chasing bugs out of the program, triggering an error exactly where it occurs, not segfaulting miles of code later.
Have a nice day, Mirsad