Re: Default array base index
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sun, 27 Jan 2008 20:36:16 +0100
On Sun, 27 Jan 2008 11:20:59 -0800 (PST), Scott Burson wrote:
I just came across this Wikipedia page:
http://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29
which claims that the default base index for arrays in Ada is 1. It
has been over 15 years since I have written any Ada, so my memory is
fuzzy, but what I recall is that there actually is no default: the
base index must always be specified explicitly when the array is
declared.
Actually both statements are wrong. As an example consider:
Foo : array (Character) of Boo;
Here the base index is neither specified nor 1. It is NUL (character).
However, it does appear that Ada culture leans toward the
use of 1 as a default (for example, the language numbers the
dimensions of the array from 1 in attribute expressions).
Maybe, when index is a signed integer type. But with modular integer types
0 as the lower bound looks quite natural. And for enumeration types the
issue makes no sense anyway.
What Ada culture leans toward is actually designing programs so that this
question would become irrelevant. An array of fixed size is defined over a
type or subtype which bounds determine the array bounds, so that there are
no illegal indices at all.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Default array base index
- From: Scott Burson
- Re: Default array base index
- References:
- Default array base index
- From: Scott Burson
- Default array base index
- Prev by Date: Default array base index
- Next by Date: ANN: GNAT/GPL Solaris 10: 2007-solaris-x86
- Previous by thread: Default array base index
- Next by thread: Re: Default array base index
- Index(es):
Relevant Pages
|