Re: Records that could be arrays



type Coordinate is
record
Row : Local_Float;
Column : Local_Float;
end record;
In mathematics, one usually gives a coordinate as (x,y), while in
graphics it's often (vertical, horizontal). Inadvertently switching
the order can be an annoying bug. But with
type Rows is new Local_Float;
type Cols is new Local_Float;
the compiler's type checking can point out such errors. In that case,
of course, you have to use a record with
Row : Rows;
Column : Cols;
and cannot use an array.
If your code might one day have to accomodate 3-D coordinates, then
for A in Axis loop
Sum := Sum + V(A)**2;
needs no change, while
Sum := V.Row**2 + V.Column**2;
will need a makeover, and thus is much less desirable.

The general point is that sometimes an array fits the problem better
and sometimes a record fits it better. A rule that says "hey, they're all
Local_Float so it should be an array" is much too limiting.
.