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,8a3e2ce4e6d56336 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-08 21:28:03 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!209.50.235.254!europa.netcrusader.net!204.127.161.3!wn3feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3AA8698B.79E68E1C@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Generic Formal Parameter for a Task Type References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 09 Mar 2001 05:24:33 GMT NNTP-Posting-Host: 12.74.128.151 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc06-news.ops.worldnet.att.net 984115473 12.74.128.151 (Fri, 09 Mar 2001 05:24:33 GMT) NNTP-Posting-Date: Fri, 09 Mar 2001 05:24:33 GMT Organization: AT&T Worldnet Xref: supernews.google.com comp.lang.ada:5565 Date: 2001-03-09T05:24:33+00:00 List-Id: "Beard, Frank" wrote: > > Why can't you have something like the following: > > generic > > type Item is limited private; > with function Terminated(the_Item : Item) return boolean; > > package Xyz is > > procedure Monitor(the_Item : Item); > ... > > end Xyz; > > You instantiate the package with the task type and supply the > Terminated function, which would look something like: > > function Terminated(the_Task : Task_Type) return boolean is > begin > return the_Task'terminated; > end Terminated; > > So, inside your generic where you are monitoring the task, you > call the supplied function. Of course, you would have to supply > a function for every task attribute you wanted to check. I know > it's not as clean as using the attribute directly, but it's not > that bad. > > I haven't tried to test this but the spec part compiles and it > seems like it should work, but I might be missing something. Yep. That works. Thanks for the inspiration. This is still a bit nastier than I hoped for. As you say, it requires a function for each attribute. This gets even worse if someone employs the Ada.Task_Attributes package. This solution requires a lot of explicit imfrastructure for the programmer. One can still not simply pass a task type to a generic package, and let that package directly deal with objects of that task type. The package is still left ignorant of the fact it is dealing with a task type. I would still like to see Ada 20XY contain a generic formal parameter type for task types and task access types. Whining aside, I am pleased to have a solution, even if it is an ugly one. Jim Rogers Colorado Springs, Colorado USA