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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ee499d03212eed3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-08 18:28:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!falcon.america.net!eagle.america.net.POSTED!not-for-mail Message-ID: <3BC252F0.E806EFE1@otelco.net> From: Larry Hazel X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en,x-ns11F8K63r3NhQ,x-ns2r2e09OnmPe2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Dynamic dispatch again References: <3BC1F97E.6EA2F1E7@san.rr.com> <_trw7.16605$IY3.11751097@news1.rdc1.sfba.home.com> <3BC2475D.535D4E72@san.rr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 08 Oct 2001 20:29:20 -0500 NNTP-Posting-Host: 66.0.32.230 X-Trace: eagle.america.net 1002590936 66.0.32.230 (Mon, 08 Oct 2001 21:28:56 EDT) NNTP-Posting-Date: Mon, 08 Oct 2001 21:28:56 EDT Organization: 24hoursupport.com Xref: archiver1.google.com comp.lang.ada:13978 Date: 2001-10-08T20:29:20-05:00 List-Id: Darren New wrote: > > tmoran@acm.org wrote: > > > > >Right now, my alternative is ... . Ugly. > > I've *always* found that if something was ugly/difficult in Ada, > > after some thought it would become clear that the approach was in > > fact a poor one, and a different approach, which worked nicely in > > Ada, was a better one. (Not to say that this alternative nice > > approach in this case is obvious. ;) > > Well, that's kind of why I'm posting here. I'm not sure what the right > approach to dynamically dispatching an entry to one of N different tasks > might be. Someone earlier mentioned using "requeue", but that seems to > suffer the same problems. I've thought of any number of different > approaches, and they're all ugly, since the point is to have a bunch of > different tasks running, and all the alternate approaches involve not > dealing with tasks. > > It seems Ada isn't quite as orthogonal as could be hoped. I'm not sure I understand what you are trying to do. What I am going to suggest is somewhat ugly to an Ada person and may be compiler dependent, but I don't think so. If the task specs are all the same: with Unchecked_Conversion; ... ... task type A is -- common spec end A; type A_Access is access A; type Task_Array is array(1..How_Many) of A_Access; task type B is -- common spec end B; type B_Access is access B; function Coerce is new Unchecked_Conversion (B_Access, A_Access); etc. Tasks : Task_Array := (new A, Coerce(new B), ....); I've seen this work in Ada 83 with the VADS compiler. Larry