* Enormous problems in one of my programs!
@ 2002-05-24 10:13 Kladde
2002-05-24 13:35 ` Ted Dennison
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Kladde @ 2002-05-24 10:13 UTC (permalink / raw)
Helllo! I have a home assignment in ADA, and sice Im not used to this
language I need some help, I would be very greatful. Below I will
insert a start, header and body file and any faults or problems you
can find I will be very happy for. Under the code I will insert the
compile failures I get when trying to compile.
All help is greatly appreciated!!
//***********************
START FILE (shouldnt contain any faults since it came with the package
i got at the start of the course):
//***************************
with Fibonacci;
use Fibonacci;
procedure Starter is
begin
Random_F.Reset(Gen =>Randomizer); -- initialize random generator
Island.Breed; -- creates first two rabbits
end;
//********************************
DECLARATION FILE (.ads file, shouldnt contain any faults either since
it too came with the package):
//********************************
with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;
package Fibonacci is
task type Female is -- Server task specification
entry Multiply;
end Female;
type Server_P is access Female; -- Type for Pointers to Server
tasks
task type Male; -- Client task specification
type Client_P is access Male; -- Type for Pointers to Client
tasks
type Servers is array (1 .. 100) of Server_P;
type Clients is array (1 .. 100) of Client_P;
subtype F_Index is Integer range 1 .. 100; -- Support for
randomness in selection of servers
package Random_F is
new Ada.Numerics.Discrete_Random(Result_Subtype => F_Index);
-- Hint : Temp:=(Random_F.Random(Gen => Randomizer) mod 17)+1;
assigns a
Randomizer : Random_F.Generator; -- Generator of psudo-randomnes
protected type Island_T is -- protected object definition
private
Pairs : Integer := 0;
Females : Servers;
Males : Clients;
entry Get_Random_Female (
Female : out Server_P );
procedure Breed;
end Island_T;
Island : Island_T; -- a protected object for
resource control
end Fibonacci;
//***************************
BODY FILE (this is the one that contains the faults since its the one
that I made :-))
//***************************
with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;
package body Fibonacci is
--H�R �R KVINNAN
task body Female is
begin
loop
accept Multiply do
Island.Breed;
end Multiply;
end loop;
end Female;
-- H�r �r mannen
task body Male is
temp : Female;
begin
delay 20.0;
loop
temp := Island.Get_Random_Female;
loop
select
temp.Multiply;
or
delay 3.0;
end select;
end loop;
delay 2.0;
end loop;
end Male;
-- H�r �r �n
protected body Island is
begin
accept Get_Random_Female(hona: out Server_P) do
hona := honor(par);
return;
end Get_Random_Female;
procedure Breed is
begin
if(par <= 100) then
hanar(par) := new Male;
honor(par) := new Female;
par := par+1;
end if;
end Breed;
end Island;
end Fibonacci;
//*********************
Here are the errors that the program produces
//************************
fibonacci.adb:51:03: missing "end Island;"
fibonacci.adb:59:03: declarations must come before "begin"
fibonacci.adb:68:01: "end Fibonnaci;" expected
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 10:13 Enormous problems in one of my programs! Kladde
@ 2002-05-24 13:35 ` Ted Dennison
2002-05-24 13:57 ` Andreas Lans
2002-05-24 14:55 ` Preben Randhol
2002-05-24 17:14 ` Stephen Leake
2 siblings, 1 reply; 8+ messages in thread
From: Ted Dennison @ 2002-05-24 13:35 UTC (permalink / raw)
Kladde wrote:
> fibonacci.adb:51:03: missing "end Island;"
> fibonacci.adb:59:03: declarations must come before "begin"
> fibonacci.adb:68:01: "end Fibonnaci;" expected
The second error seems quite self-evident. I suspect when you fix it,
the other ones will go away as well.
Three errors isn't bad at all. I think my first ever Fortran program
netted me 100 *screens* full of errors. :-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 13:35 ` Ted Dennison
@ 2002-05-24 13:57 ` Andreas Lans
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Lans @ 2002-05-24 13:57 UTC (permalink / raw)
"Ted Dennison" <dennison@telepath.com> skrev i meddelandet
news:3CEE41B6.8080005@telepath.com...
> Kladde wrote:
>
> > fibonacci.adb:51:03: missing "end Island;"
> > fibonacci.adb:59:03: declarations must come before "begin"
> > fibonacci.adb:68:01: "end Fibonnaci;" expected
>
>
> The second error seems quite self-evident. I suspect when you fix it,
> the other ones will go away as well.
>
>
> Three errors isn't bad at all. I think my first ever Fortran program
> netted me 100 *screens* full of errors. :-)
>
>
>
What can I do o solve the second error then??
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 10:13 Enormous problems in one of my programs! Kladde
2002-05-24 13:35 ` Ted Dennison
@ 2002-05-24 14:55 ` Preben Randhol
2002-05-24 15:26 ` Andreas Lans
2002-05-24 17:14 ` Stephen Leake
2 siblings, 1 reply; 8+ messages in thread
From: Preben Randhol @ 2002-05-24 14:55 UTC (permalink / raw)
On 24 May 2002 03:13:58 -0700, Kladde wrote:
> Helllo! I have a home assignment in ADA, and sice Im not used to this
> language I need some help, I would be very greatful. Below I will
> insert a start, header and body file and any faults or problems you
> can find I will be very happy for. Under the code I will insert the
> compile failures I get when trying to compile.
>
> All help is greatly appreciated!!
There should not be a begin in a protected body and your accept should
be a entry (unless I have misunderstood the little I have read on
tasks):
Read section 14.2 (page 79) of
http://www.adapower.com/learn/adadistilled.pdf
and also look at:
http://www.it.bton.ac.uk/staff/je/adacraft/ch19.htm
http://burks.bton.ac.uk/burks/language/ada/ada95.pdf (Chapter 20, page
311->)
Preben
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 14:55 ` Preben Randhol
@ 2002-05-24 15:26 ` Andreas Lans
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Lans @ 2002-05-24 15:26 UTC (permalink / raw)
"Preben Randhol" <randhol+abuse@pvv.org> skrev i meddelandet
news:slrnaesl2q.5ab.randhol+abuse@kiuk0152.chembio.ntnu.no...
> On 24 May 2002 03:13:58 -0700, Kladde wrote:
> > Helllo! I have a home assignment in ADA, and sice Im not used to this
> > language I need some help, I would be very greatful. Below I will
> > insert a start, header and body file and any faults or problems you
> > can find I will be very happy for. Under the code I will insert the
> > compile failures I get when trying to compile.
> >
> > All help is greatly appreciated!!
>
> There should not be a begin in a protected body and your accept should
> be a entry (unless I have misunderstood the little I have read on
> tasks):
>
> Read section 14.2 (page 79) of
> http://www.adapower.com/learn/adadistilled.pdf
>
> and also look at:
>
> http://www.it.bton.ac.uk/staff/je/adacraft/ch19.htm
> http://burks.bton.ac.uk/burks/language/ada/ada95.pdf (Chapter 20, page
> 311->)
>
> Preben
Sorry, but I still dont understand, can someone please tell me how to solve
the problems??
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 10:13 Enormous problems in one of my programs! Kladde
2002-05-24 13:35 ` Ted Dennison
2002-05-24 14:55 ` Preben Randhol
@ 2002-05-24 17:14 ` Stephen Leake
2002-05-25 1:26 ` Liao Choon Way
2 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2002-05-24 17:14 UTC (permalink / raw)
b99andla@student.his.se (Kladde) writes:
> Helllo! I have a home assignment in ADA, and sice Im not used to this
> language I need some help, I would be very greatful. Below I will
> insert a start, header and body file and any faults or problems you
> can find I will be very happy for. Under the code I will insert the
> compile failures I get when trying to compile.
>
> All help is greatly appreciated!!
The biggest problem is the syntax for a protected body. Also, you have
"Island_T" in the spec, but "Island" in the body. Fix those problems,
and you'll get more helpful errors from the compiler.
Here is the correct syntax for the body of Island_T:
protected body Island_T is
entry Get_Random_Female(hona: out Server_P) when True is
begin
hona := honor(par);
return;
end Get_Random_Female;
procedure Breed is
begin
if(par <= 100) then
hanar(par) := new Male;
honor(par) := new Female;
par := par+1;
end if;
end Breed;
end Island_T;
The compiler still reports errors here, but you should be able to
figure them out.
--
-- Stephe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-24 17:14 ` Stephen Leake
@ 2002-05-25 1:26 ` Liao Choon Way
2002-05-25 15:31 ` Adrian Hoe
0 siblings, 1 reply; 8+ messages in thread
From: Liao Choon Way @ 2002-05-25 1:26 UTC (permalink / raw)
Haa haa... replies seem to come from people who have quite some experience
teaching... giving away some hints but not too much as to spoon-feed...
As a software engineer I'd rarely have that kind of patience... if someone
asks me about Ada (we're mostly a C/C++ shop) I'd
1. Spoonfeed him so he/she doesn't bother me anymore... but usually they
suffer indigestion.
2. Tell him/her I'm busy and I look for them when I'm free...
"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:ud6vlmprn.fsf@gsfc.nasa.gov...
> b99andla@student.his.se (Kladde) writes:
>
> > Helllo! I have a home assignment in ADA, and sice Im not used to this
> > language I need some help, I would be very greatful. Below I will
> > insert a start, header and body file and any faults or problems you
> > can find I will be very happy for. Under the code I will insert the
> > compile failures I get when trying to compile.
> >
> > All help is greatly appreciated!!
>
> The biggest problem is the syntax for a protected body. Also, you have
> "Island_T" in the spec, but "Island" in the body. Fix those problems,
> and you'll get more helpful errors from the compiler.
>
> Here is the correct syntax for the body of Island_T:
>
> protected body Island_T is
>
> entry Get_Random_Female(hona: out Server_P) when True is
> begin
> hona := honor(par);
> return;
> end Get_Random_Female;
>
>
> procedure Breed is
> begin
> if(par <= 100) then
> hanar(par) := new Male;
> honor(par) := new Female;
> par := par+1;
> end if;
> end Breed;
>
> end Island_T;
>
> The compiler still reports errors here, but you should be able to
> figure them out.
>
>
> --
> -- Stephe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Enormous problems in one of my programs!
2002-05-25 1:26 ` Liao Choon Way
@ 2002-05-25 15:31 ` Adrian Hoe
0 siblings, 0 replies; 8+ messages in thread
From: Adrian Hoe @ 2002-05-25 15:31 UTC (permalink / raw)
"Liao Choon Way" <choonway@stts.com.sg> wrote in message news:<acmp5k$narb$1@engel.scvmaxonline.com.sg>...
> Haa haa... replies seem to come from people who have quite some experience
> teaching... giving away some hints but not too much as to spoon-feed...
>
> As a software engineer I'd rarely have that kind of patience... if someone
> asks me about Ada (we're mostly a C/C++ shop) I'd
>
> 1. Spoonfeed him so he/she doesn't bother me anymore... but usually they
> suffer indigestion.
> 2. Tell him/her I'm busy and I look for them when I'm free...
>
You will spoil him/her. He/She will never learn. Programming isn't
just problem solving. Is it?
You will have no trouble at all if you just ignore them. Haa haa...
;-)
--
-- Adrian Hoe
-- http://adrianhoe.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-05-25 15:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-24 10:13 Enormous problems in one of my programs! Kladde
2002-05-24 13:35 ` Ted Dennison
2002-05-24 13:57 ` Andreas Lans
2002-05-24 14:55 ` Preben Randhol
2002-05-24 15:26 ` Andreas Lans
2002-05-24 17:14 ` Stephen Leake
2002-05-25 1:26 ` Liao Choon Way
2002-05-25 15:31 ` Adrian Hoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox