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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable 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-09 16:20:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed.icl.net!isdnet!enst!enst.fr!not-for-mail From: "Robert C. Leif, Ph.D." Newsgroups: comp.lang.ada Subject: RE: Generic Formal Parameter for a Task Type Date: Fri, 9 Mar 2001 16:14:49 -0800 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 984183487 12857 137.194.161.2 (10 Mar 2001 00:18:07 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 10 Mar 2001 00:18:07 +0000 (UTC) To: Return-Path: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 In-Reply-To: <3AA95037.77EFEBFA@averstar.com> Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:5593 Date: 2001-03-09T16:14:49-08:00 From: Bob Leif To: Tucker Taft et al. You wrote: "If you wanted to avoid generics, you could define an abstract limited tagged type (say "Has_Task") which had various (abstract) primitive operations, including at least a "Task_ID" function. You would then extend from this type by adding a component of the task type of interest (and of course override the abstract primitives as appropriate)." Can you include the "Has_Task" in a generic package; or are the two approaches mutually exclusive for tasks? -----Original Message----- From: comp.lang.ada-admin@ada.eu.org [mailto:comp.lang.ada-admin@ada.eu.org]On Behalf Of Tucker Taft Sent: Friday, March 09, 2001 1:51 PM To: comp.lang.ada@ada.eu.org Subject: Re: Generic Formal Parameter for a Task Type James Rogers wrote: > > "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. ... Why not have a formal function that returns the Task_ID, rather than 'Terminated? That way, you can use the Ada.Task_Identification and Ada.Task_Attributes packages to get whatever else you need from the task, including task attributes... If you wanted to avoid generics, you could define an abstract limited tagged type (say "Has_Task") which had various (abstract) primitive operations, including at least a "Task_ID" function. You would then extend from this type by adding a component of the task type of interest (and of course override the abstract primitives as appropriate). You could then manipulate objects of type Has_Task'Class, or references there-to, in a "Java"-like way ;-). You could also pass in any extension of Has_Task to a generic with a formal tagged derived type of "type My_Task is new Has_Task with private;". The possibilities are endless... > Jim Rogers > Colorado Springs, Colorado USA -- -Tucker Taft stt@avercom.net http://www.averstar.com/~stt/ Chief Technology Officer, AverCom Corporation (A Titan Company) Burlington, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/services/ebusiness_applications.html)