From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx20.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Thunderbird/36.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: passing parametars as determinants References: <4e918e9a-f2f1-4c9e-97ec-62b558d4621c@googlegroups.com> In-Reply-To: <4e918e9a-f2f1-4c9e-97ec-62b558d4621c@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Wed, 22 Oct 2014 15:57:13 UTC Organization: TeraNews.com Date: Wed, 22 Oct 2014 09:57:16 -0600 X-Received-Bytes: 3357 X-Received-Body-CRC: 1505219443 Xref: news.eternal-september.org comp.lang.ada:22663 Date: 2014-10-22T09:57:16-06:00 List-Id: On 10/22/2014 5:55 AM, compguy45@gmail.com wrote: > task type myTaskType (a: Integer; b: Integer; c: access myOtherType); > > > This is where i create tasks..... > > > := new myTaskType(a=> i, b => j,c => access'myOtherType); > > I get compiler error "reserved word "access" cannot be used as identifier" > Here's an example of using an access discriminant in a task-type: With Ada.Text_IO; procedure Test is -- This is the type for the data to be passed to the task-type. Type Info is array (positive range <>) of Integer; -- The task-type's public interface. Task Type Print_Task( Info_Param : not null access Info ) is entry Print ( Index : in Positive ); entry Done; end Print_Task; -- The body of the task-type. Task body Print_Task is subtype Data_Range is Positive range Info_Param'Range; Procedure Put( Index : Data_Range ) is begin Ada.Text_IO.Put_Line("Data(" & Integer'Image(Index) & " ) ->" & ASCII.HT & Integer'Image(Info_Param(Index)) ); end Put; -- Variable indicating if we're finished. Finished : Boolean := False; begin loop -- Select lets us accept things non-sequentially; A or B, -- rather than A then B. select accept Done do -- We're free to exit the task. Finished:= True; end Done; or accept Print (Index : in Positive) do -- If the input is outside the range of the data, we print -- an error-message, otherwise we desplay the indicated data. if Index not in Data_Range then Ada.Text_IO.Put_Line("[ERROR] Index out of range."); else Put(Index); end if; end Print; end select; -- When Finished is flagged, we break out of the loop. exit when Finished; end loop; Ada.Text_IO.Put_Line("Goodbye."); end Print_Task; -- This is the actual object of data we will pass to the task. Data : aliased Info:= (8,3,-1,2); -- The actual task. SOME_TASK : Print_Task( Info_Param => Data'Access ); use Ada.Text_IO; begin SOME_TASK.Print(3); SOME_TASK.Done; -- Put_Line( "P(24) =" & P(K'Last)'Img ); end Test;