C official DOD language?
cspw quagga
cspw.quagga at p0.f4.n494.z5.fidonet.org
Sun Jun 10 08:04:22 AEST 1990
>In article <1631 at dinl.mmc.UUCP> noren at dinl.UUCP (Charles Noren) writes:
>> C Advantage list:
>> 5. Array subscripts in C must start with zero, which for
>> some is counter intuitive
>
IMHO, our experience with flexible lower bounds has been appalling, and
not a very useful programming feature. The Pascal/Modula camp still
has difficulty deciding whether
ARRAY [1..10] OF T;
is equivalent/assignment compatible with
ARRAY ['A'..'J'] OF T;
And even a cursory glance at most Modula implementations can show the
difficulty of trying to provide a general mechanism with variable
lower bounds. (For example, when one passes an array to a formal
parameter which is an 'open' array, the bounds are automatically
'renumbered' as if they began at 0. Many library procedures (eg Pos)
that are widely used return HIGH(array)+1 to denote a non-found condition,
or return the position of the located element AS IF THE ARRAY HAD BEEN
NUMBERED FROM 0. Declaring ARRAY [1..10] OF CHAR and trying to use the
library procedures is a recipe for a complete mess.
So I think fixed lower bounds are more natural and will always provide
better consistency and abstraction in the language. I think it is a
minor argument about whether 0 or 1 is the chosen lower bound (this was
a C vs Fortan thread, once upon a time).
If the C convention is counter-intuitive for some, they'll need to
adjust their intuition.
Pete
--
EP Wentworth - Dept. of Computer Science - Rhodes University - Grahamstown.
Internet: cspw.quagga at f4.n494.z5.fidonet.org
Uninet: cspw at quagga
uucp: ..uunet!m2xenix!quagga!cspw
--
uucp: uunet!m2xenix!puddle!5!494!4.0!cspw.quagga
Internet: cspw.quagga at p0.f4.n494.z5.fidonet.org
More information about the Comp.lang.c
mailing list