comp.lang.ada
 help / color / mirror / Atom feed
* Newbie - error with 'Limited Type' assignment
@ 2001-01-22 22:56 Baldy
  2001-01-22 23:50 ` tmoran
  0 siblings, 1 reply; 2+ messages in thread
From: Baldy @ 2001-01-22 22:56 UTC (permalink / raw)


Hi All,

I hope someone here can help me out? this ADA stuff is new to me.

I'm trying to pass a FILE_TYPE reference to a task within a seperate package
from the main program. The compiler, AdaGIDE, says this is not allowed as it
is a limited type. How can I do this correctly.

Here's a snippet of the code i'm using:

package body PhonePkg is
    task body phone_line is
        This_Simulation_Data : FILE_TYPE;
    begin
        accept Start_Lines(Simulation_Data : in FILE_TYPE)
            This_Simulation_Data := Simulation_Data; << error here
        end Start_Lines;
    end phone_line;
end PhonePkg;


Any help will be greatly appreciated

Thanks,
Mike
Mike@Delfan.co.uk











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

* Re: Newbie - error with 'Limited Type' assignment
  2001-01-22 22:56 Newbie - error with 'Limited Type' assignment Baldy
@ 2001-01-22 23:50 ` tmoran
  0 siblings, 0 replies; 2+ messages in thread
From: tmoran @ 2001-01-22 23:50 UTC (permalink / raw)


> The compiler, AdaGIDE, says this is not allowed
> ...
>   task body phone_line is
> ...
>       accept Start_Lines(Simulation_Data : in FILE_TYPE)
>           This_Simulation_Data := Simulation_Data; << error here
>       end Start_Lines;
  1) You could pass a pointer to the File_Type.  Or make an array
of File_Type elements and pass an index to Start_Lines.
  2) When an Ada compiler complains about something, it's wise to
think hard about whether you really want to do what you wrote.  In
this case, after "end Start_Lines;" you will have two different
tasks reading/writing/closing the same file:  the Phone_Line task and
its caller.  That's certainly a situation that's highly likely to get
you into trouble.  If the caller doesn't actually do anything but
open or create the file it passes to Phone_Line, perhaps it should
instead pass the name and let Phone_Line open/create its own
This_Simulation_Data file.



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

end of thread, other threads:[~2001-01-22 23:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-22 22:56 Newbie - error with 'Limited Type' assignment Baldy
2001-01-22 23:50 ` tmoran

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