From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: passing parametars as determinants
Date: Wed, 22 Oct 2014 10:51:29 +0200
Date: 2014-10-22T10:51:29+02:00 [thread overview]
Message-ID: <m27r6d$2i1$1@dont-email.me> (raw)
In-Reply-To: <a3ba492e-7ef4-4ebb-b2fb-0f4b668a2ad3@googlegroups.com>
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;
next prev parent reply other threads:[~2014-10-22 8:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 5:12 passing parametars as determinants compguy45
2014-10-22 5:16 ` compguy45
2014-10-22 5:22 ` Simon Wright
2014-10-22 11:55 ` compguy45
2014-10-22 12:39 ` Dennis Lee Bieber
2014-10-22 15:57 ` Shark8
2014-10-22 6:11 ` mockturtle
2014-10-22 8:51 ` Georg Bauhaus [this message]
2014-10-22 17:25 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox