* FW: Ada 200X
@ 2003-06-03 12:13 Erlo Haugen
2003-06-03 14:49 ` Preben Randhol
2003-06-03 15:16 ` Vinzent Hoefler
0 siblings, 2 replies; 4+ messages in thread
From: Erlo Haugen @ 2003-06-03 12:13 UTC (permalink / raw)
To: 'comp.lang.ada@ada.eu.org'
-----Original Message-----
From: Gautier Write-only [mailto:gautier@somewhere.nil]
Sent: 3. juni 2003 04:46
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada 200X
And838N@netscape.net wrote:
> I've heard professors say they don't like Ada because it's slow and
> does all those "bounds" checking "things".
>They are misinformed: Ada is slow when the bounds checking is ON. After
some debugging phase, if you want, you can turn all checkings OFF ! And as
you point out, better to have> the possibility of bounds checking than
not... ________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
<
Wouldn't
subtype day_number is natural range 1..31;
type month_days is array (day_number) of some_other_type;
eliminate the boundschecking??
Erlo Haugen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FW: Ada 200X
2003-06-03 12:13 FW: Ada 200X Erlo Haugen
@ 2003-06-03 14:49 ` Preben Randhol
2003-06-03 14:55 ` John R. Strohm
2003-06-03 15:16 ` Vinzent Hoefler
1 sibling, 1 reply; 4+ messages in thread
From: Preben Randhol @ 2003-06-03 14:49 UTC (permalink / raw)
Erlo Haugen wrote:
> Wouldn't
> subtype day_number is natural range 1..31;
> type month_days is array (day_number) of some_other_type;
>
> eliminate the boundschecking??
Not sure what you mean here.
procedure testing is
subtype day_number is natural range 1..31;
type month_days is array (day_number) of Integer;
Mai : month_days;
begin
Mai (32) := 1;
end testing;
gnatmake testing.adb
gnatgcc -c testing.adb
testing.adb:6:09: warning: value not in range of type "day_number"
defined at line 2
testing.adb:6:09: warning: "constraint_error" will be raised at run time
gnatbind -x testing.ali
gnatlink testing.ali
./testing
raised CONSTRAINT_ERROR : testing.adb:6
--
Preben Randhol http://www.pvv.org/~randhol/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FW: Ada 200X
2003-06-03 14:49 ` Preben Randhol
@ 2003-06-03 14:55 ` John R. Strohm
0 siblings, 0 replies; 4+ messages in thread
From: John R. Strohm @ 2003-06-03 14:55 UTC (permalink / raw)
"Preben Randhol" <randhol+abuse@pvv.org> wrote in message
news:slrnbdpdan.87p.randhol+abuse@kiuk0152.chembio.ntnu.no...
> Erlo Haugen wrote:
> > Wouldn't
> > subtype day_number is natural range 1..31;
> > type month_days is array (day_number) of some_other_type;
> >
> > eliminate the boundschecking??
>
> Not sure what you mean here.
>
> procedure testing is
> subtype day_number is natural range 1..31;
> type month_days is array (day_number) of Integer;
> Mai : month_days;
> begin
> Mai (32) := 1;
> end testing;
>
> gnatmake testing.adb
> gnatgcc -c testing.adb
> testing.adb:6:09: warning: value not in range of type "day_number"
> defined at line 2
> testing.adb:6:09: warning: "constraint_error" will be raised at run
time
> gnatbind -x testing.ali
> gnatlink testing.ali
>
>
> ./testing
>
> raised CONSTRAINT_ERROR : testing.adb:6
What he meant is that the naive generated code would be
if 32 <= 31 then
Mai(32) := 1;
else
raise constraint_error;
end if;
but then the compiler would notice that 32 <= 31 is a static expression,
evaluate it, and simplify the code to:
raise constraint_error;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FW: Ada 200X
2003-06-03 12:13 FW: Ada 200X Erlo Haugen
2003-06-03 14:49 ` Preben Randhol
@ 2003-06-03 15:16 ` Vinzent Hoefler
1 sibling, 0 replies; 4+ messages in thread
From: Vinzent Hoefler @ 2003-06-03 15:16 UTC (permalink / raw)
Erlo Haugen wrote:
>Wouldn't
>subtype day_number is natural range 1..31;
>type month_days is array (day_number) of some_other_type;
>eliminate the boundschecking??
Inside a function that takes a type day_number as parameter to use it
on an array of type month_days, it definitely should.
The bounds checking should occur *before* calling the function with an
out of range parameter then. Quite hard to determine in C when you
only have ints that can mean everything.
Vinzent.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-06-03 15:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03 12:13 FW: Ada 200X Erlo Haugen
2003-06-03 14:49 ` Preben Randhol
2003-06-03 14:55 ` John R. Strohm
2003-06-03 15:16 ` Vinzent Hoefler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox