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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!.POSTED!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: passing parametars as determinants Date: Wed, 22 Oct 2014 10:51:29 +0200 Organization: A noiseless patient Spider Message-ID: References: Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 22 Oct 2014 08:51:25 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="1c125eb3cdfe760b4299210375a7ff70"; logging-data="2625"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BmnA1IWA2pXWkSgM/mDGKKrVZrs6aERA=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Cancel-Lock: sha1:53Aa/df75toCUCxW+UYfBZNak+4= Xref: news.eternal-september.org comp.lang.ada:22656 Date: 2014-10-22T10:51:29+02:00 List-Id: On 22.10.14 08:11, mockturtle wrote: > Why are not we allowed to use generic types as discriminants? Honestly, I do not know, I have always been curious... Note, however, that the task "parameters" are actually called "discriminants," so I guess they are closer (in some sense) to the record discriminants. To make composite objects accessible to a task use visibility. They are not like discriminants used to create variant parts, and can be used more freely: package Run_Task is type Text is access String; type Place is range 0 .. 99; type Data is array (Place range <>) of Text; procedure Run_It (Env : in out Data); end Run_Task; with Ada.Text_Io; package body Run_Task is procedure Run_It (Env : in out Data) is task type My_Task (A, B: Place) is entry Go; end My_task; task body My_Task is begin accept Go; for K in Place range A .. B loop declare Line : Text renames Env (K); begin Line (Line'First) := '\'; Line (Line'Last) := '_'; end; end loop; end My_Task; T1 : My_Task (A => Place'First, B => (Place'Last - Place'First) / 2); T2 : My_Task (A => (Place'Last - Place'First) / 2 + 1, B => Place'Last); begin -- Run_It T1.Go; T2.Go; end Run_It; Panel : Data := (Place'range => new String'(1 .. 80 => '*')); begin Run_It (Env => Panel); for Row in Panel'Range loop Ada.Text_Io.Put_Line (Panel (Row).all); end loop; end Run_Task;