From: "Gautier direct_replies_not_read" <gautier_niouzes@hotmail.com>
Subject: Re: more to ada paper critic
Date: Mon, 17 Jun 2002 15:16:57 +0000
Date: 2002-06-17T15:16:57+00:00 [thread overview]
Message-ID: <mailman.1024327022.27984.comp.lang.ada@ada.eu.org> (raw)
Immanuel Scholz:
>Oh come. Arent there race conditions when initializing more than these
>"before the main"s. This solution seems quite similar to C++'s problem
>of initializing global statics. Example: (forgive any syntax-errors I
>havent got GNAT to run until now ;-)
>function Prob1 return integer is
>begin
> return Var2;
>end Prob1;
>
>function Prob2 return integer is
>begin
> return Var1;
>end Prob2;
>
>Var1 : constant integer := Prob1;
>Var2 : constant integer := Prob2;
This obviously don't pass the compilation,
since Var1 and Var2 are undefined: this is the
one-pass design of Ada (like Pascal, unlike C or Fortran)
Anyway it is interesting to try.
-- -- -- -- -- -- -- -- --
procedure kiki1 is
function Prob1 return integer is
begin
return Var2;
end Prob1;
function Prob2 return integer is
begin
return Var1;
end Prob2;
Var1 : constant integer := Prob1;
Var2 : constant integer := Prob2;
begin
null;
end;
-- -- -- -- -- -- -- -- --
GNAT says:
kiki1.adb:5:12: "Var2" is undefined
kiki1.adb:10:12: "Var1" is undefined
If I push a bit more and "forward" the definition of Prob1, Prob2:
-- -- -- -- -- -- -- -- --
procedure kiki2 is
function Prob1 return integer;
function Prob2 return integer;
Var1 : constant integer := Prob1;
Var2 : constant integer := Prob2;
function Prob1 return integer is
begin
return Var2;
end Prob1;
function Prob2 return integer is
begin
return Var1;
end Prob2;
begin
null;
end;
-- -- -- -- -- -- -- -- --
GNAT compiles, but says:
kiki2.adb:6:30: warning: cannot call "Prob1" before body seen
kiki2.adb:6:30: warning: Program_Error will be raised at run time
kiki2.adb:7:30: warning: cannot call "Prob2" before body seen
kiki2.adb:7:30: warning: Program_Error will be raised at run time
Running kiki2 produces:
raised PROGRAM_ERROR : kiki2.adb:6
____________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/index.htm#Ada
NB: For a direct answer, address on the Web site!
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
next reply other threads:[~2002-06-17 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-17 15:16 Gautier direct_replies_not_read [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-06-17 15:26 more to ada paper critic Gautier direct_replies_not_read
2002-06-18 13:30 ` Immanuel Scholz
2002-06-18 13:35 ` Steve O'Neill
2002-06-18 17:59 ` Christoph Schlegel
2002-06-19 20:41 ` Immanuel Scholz
2002-06-20 19:39 ` Christoph Schlegel
2002-06-19 16:05 ` Britt Snodgrass
2002-06-17 11:33 Grein, Christoph
2002-06-17 10:28 Immanuel Scholz
2002-06-17 17:23 ` Ted Dennison
2002-06-17 18:07 ` Hyman Rosen
2002-06-18 1:50 ` Ted Dennison
2002-06-18 5:38 ` Eric G. Miller
2002-06-18 13:42 ` Immanuel Scholz
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox