comp.lang.ada
 help / color / mirror / Atom feed
* Problems with assignment
@ 2002-05-24 16:22 Andreas Lans
  2002-05-24 17:19 ` Stephen Leake
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andreas Lans @ 2002-05-24 16:22 UTC (permalink / raw)


So, the prior problem is solved, but now a new one has come up. Im trying to
get the Get_Random_Female procedure to return a female to be stored in the
temp variable. In short it looks like this.When I try to compile this it
says: Left hand of assignment must not be limited type. Its about the
declaration temp:=Island.Get_Random_Female.Whats the problem??

temp : Female;

temp := Island.Get_Random_Female;

entry Get_Random_Female(Female : out Server_P)

when Pairs <= 100 is

begin

Female := Females(pairs);

return;

end Get_Random_Female;





When I try this I get the following errors:



Left hand of assignment must not be limited type

Accept statement cannot return value










^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with assignment
  2002-05-24 16:22 Problems with assignment Andreas Lans
@ 2002-05-24 17:19 ` Stephen Leake
  2002-05-24 17:44 ` Jay Quinn
  2002-05-24 18:15 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Leake @ 2002-05-24 17:19 UTC (permalink / raw)


"Andreas Lans" <b99andla@student.his.se> writes:

> So, the prior problem is solved, but now a new one has come up. Im trying to
> get the Get_Random_Female procedure to return a female to be stored in the
> temp variable. In short it looks like this.When I try to compile this it
> says: Left hand of assignment must not be limited type. Its about the
> declaration temp:=Island.Get_Random_Female.Whats the problem??

The problem is that the variable 'temp' is of type 'Female', which is
a limited type. You cannot assign objects of a limited type.

One solution (which is really what you are asking for; the compiler
told you the problem :), is to use an access type:

type Female_Access is access all Female;

On the other hand, I have not read your program in detail, so this may
not be the correct approach.

Female is a task type, which is by definition limited. Maybe you need
an array of "Females", and return an index to one. Or an array of
"Female_Access". Ask your professor which is better.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with assignment
  2002-05-24 16:22 Problems with assignment Andreas Lans
  2002-05-24 17:19 ` Stephen Leake
@ 2002-05-24 17:44 ` Jay Quinn
  2002-05-24 18:15 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Jay Quinn @ 2002-05-24 17:44 UTC (permalink / raw)



"Andreas Lans" <b99andla@student.his.se> wrote in message
news:sNtH8.39758$n4.8847077@newsc.telia.net...
> So, the prior problem is solved, but now a new one has come up. Im trying
to
> get the Get_Random_Female procedure to return a female to be stored in the
> temp variable. In short it looks like this.When I try to compile this it
> says: Left hand of assignment must not be limited type. Its about the
> declaration temp:=Island.Get_Random_Female.Whats the problem??
>
> temp : Female;
>
> temp := Island.Get_Random_Female;
>
> entry Get_Random_Female(Female : out Server_P)
>
> when Pairs <= 100 is
>
> begin
>
> Female := Females(pairs);
>
> return;
>
> end Get_Random_Female;
>
> When I try this I get the following errors:
>
> Left hand of assignment must not be limited type
>
> Accept statement cannot return value

Here's a hint:

Are you calling a procedure or a function?  How are values returned when
calling a procedure?  How are values returned when calling a function?


--
Jay






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with assignment
  2002-05-24 16:22 Problems with assignment Andreas Lans
  2002-05-24 17:19 ` Stephen Leake
  2002-05-24 17:44 ` Jay Quinn
@ 2002-05-24 18:15 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Preben Randhol @ 2002-05-24 18:15 UTC (permalink / raw)


On Fri, 24 May 2002 16:22:48 GMT, Andreas Lans wrote:


Get_Random_Female(Female : out Server_P)

Would the above fit a procedure or function definition?

Answer after reading:

   http://www.it.bton.ac.uk/staff/je/adacraft/ch04.htm

Then you really ought to know what to do.

Preben



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-24 18:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-24 16:22 Problems with assignment Andreas Lans
2002-05-24 17:19 ` Stephen Leake
2002-05-24 17:44 ` Jay Quinn
2002-05-24 18:15 ` Preben Randhol

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