From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Need Help On Ada95 Problem
Date: Fri, 10 Feb 2012 15:03:26 -0500
Date: 2012-02-10T15:03:26-05:00 [thread overview]
Message-ID: <wcck43ua229.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: jh3dab$lo$1@dont-email.me
"Alex" <alex@foo.invalid> writes:
> I'm curious about your code sample:
>
> X : String(0 .. -1000);
>
> I tried it and it works, but I don't understand how it's possible.
> String is defined in ARM 3.6.3 as
>
> type String is array(Positive range <>) of Character;
>
> and your range is definitely outside of Positive. If I try
>
> X : String(0 .. 500);
>
> I get the expected compiler error.
Constraint_Error at run-time, I assume.
And maybe a compile-time warning (which you wouldn't
get if 500 were known only at run time).
>...What's going on that allows the
> range to be from 0 to a negative number?
There is a check that the bounds belong to the index subtype,
but that only applies if it's not a null range. For String,
you certainly want to allow 1..0 for an empty string.
Allowing 0..0 or 0..-1000 for String is a language
design flaw, which has been discussed here many times.
For that matter, allowing 5..10 is a flaw.
This causes needless inefficiency and obscure bugs.
- Bob
next prev parent reply other threads:[~2012-02-10 20:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 1:03 Need Help On Ada95 Problem Will
2012-02-09 1:51 ` Robert A Duff
2012-02-09 2:01 ` Shark8
2012-02-10 1:36 ` BrianG
2012-02-10 2:22 ` Shark8
2012-02-10 5:32 ` Alex
2012-02-10 15:19 ` Shark8
2012-02-10 15:45 ` Alex
2012-02-10 20:07 ` Robert A Duff
2012-02-12 19:40 ` Will
2012-02-12 19:42 ` Will
2012-02-12 22:26 ` Robert A Duff
2012-02-13 0:41 ` Will
2012-02-13 0:43 ` Nasser M. Abbasi
2012-02-10 5:45 ` Alex
2012-02-10 13:29 ` Robert A Duff
2012-02-10 13:50 ` Alex
2012-02-10 14:30 ` Robert A Duff
2012-02-10 15:32 ` Alex
2012-02-10 20:03 ` Robert A Duff [this message]
2012-02-13 3:28 ` BrianG
2012-02-10 8:47 ` Simon Wright
2012-02-09 3:38 ` Alex
[not found] ` <90a10801-440b-4a31-88d0-f0f7c17137f1@eb6g2000vbb.googlegroups.com>
2012-02-09 13:35 ` Alex
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox