comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: HOW TO FIX THIS IN ADA?
Date: Thu, 22 Feb 2001 07:17:55 GMT
Date: 2001-02-22T07:17:55+00:00	[thread overview]
Message-ID: <D23l6.16524$5M5.1404033@news1.frmt1.sfba.home.com> (raw)
In-Reply-To: 6Izk6.161065$Pm2.3005370@news20.bellglobal.com

> with Ada.Text_IO; use Ada.Text_IO;
  Ada.Text_IO is never used in this program.
>
> PROCEDURE  Random(Output) IS ;
  what kind of parameter is Output?  in, out, integer, float, ???
  It's never referenced in the program anyway
  The ';' is illegal and should be dropped
>     seed1 = 5; seed2 = 10000; seed3 = 3000;
  Presumably these '=' are supposed to be ':='?  But of course
  none of seed1, seed2, or seed3 has been declared.  Given the
  later use, perhaps these should be "seed1 : constant integer := 5;" etc
>         x, y, z : integer;
>         looop : integer;
   'looop' is never used.
>     FUNCTION   Unif return real is
>         tmp : real;
  I see no type declaration for 'real' - probably meant 'float'
>         Begin
>         x := 171*(x mod 177) - 2*(x div 177);
  There is no 'div' operator.  Since x is integer, x/177 does the job.
>         if x<0 then x := x + 30269;
  Is there supposed to be an 'end if;' here, or is it supposed to be elsewhere?
>         y := 172*(y mod 176) -35*(y div 176);
  There is no 'div' operator.  Since y is integer, y/176 does the job.
>         if y<0 then y := y + 30307;
  Is there supposed to be an 'end if;' here, or is it supposed to be elsewhere?
>         z := 170*(z mod 178) -63*(z div 178);
  There is no 'div' operator.  Since z is integer, z/178 does the job.
>         if z<0 then z := z + 30323;
  Is there supposed to be an 'end if;' here, or is it supposed to be elsewhere?
>         tmp :=  x/30269.0 + y/30307.0 + z/30323.0;
  Since x, y, and z are Integer, this is illegal.  Probably want 'float(x)' etc
>         Unif := tmp - trunc(tmp);
  Where is function 'trunc' defined?
  Where is a 'return' statement and what should it return?
>         End;  {Unif}
  '{Unif}' is not Ada.  Probably meant "End Unif;"
>     BEGIN
>     x := seed1; y := seed2; z := seed3;
>     for looop := 1.. 1000 loop
  The ":=" is wrong, should be "in"
  The for-loop will automatically declare a new variable for its index
  'looop' - it will not use the one declared above
>         writeln(loop:4, ' ==> ', unif:7:5);
  What do "loop:4" and "unif:7:5" mean?
  multicharacter strings are delimited with ", single character literals
  with '  So this probably should be   "  ==> "
  The string concatenation operator is '&', eg onething & "  ==> " & another
  There is no procedure "writeln" declared anywhere.
  Probably this is meant to be "put", or "put_line", in which case
  the line with-ing Ada.Text_IO should be restored.
>     END loop;
>   END unif;
  This is the end of procedure Random, not of function Unif
Get an Ada compiler and it will tell you all this much quicker than c.l.a.



  parent reply	other threads:[~2001-02-22  7:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-20 19:37 HOW TO FIX THIS IN ADA? Munir Albeelbisi
2001-02-20 20:37 ` Pascal Obry
2001-02-20 20:38 ` How to write this in Ada, was " tmoran
2001-02-21  8:56 ` Martin Dowie
2001-02-22  4:44 ` Lao Xiao Hai
2001-02-22 17:48   ` Pascal Obry
2001-02-23  3:22     ` Lao Xiao Hai
2001-02-23  4:08     ` Jeffrey Carter
2001-02-23 17:18       ` Pascal Obry
2001-02-24  4:40         ` Jeffrey Carter
2001-02-24  9:22           ` Pascal Obry
2001-02-22  7:17 ` tmoran [this message]
2001-02-22 16:43   ` Al Christians
2001-02-23  2:21 ` William J. Thomas
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox