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-Thread: a07f3367d7,c7ff90b15f15636c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news2.arglkargh.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Runtime type selection Date: Mon, 12 Oct 2009 18:42:56 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <2c15c8a6-b555-4d08-8fe6-f77cb207e7a6@k33g2000yqa.googlegroups.com> <4ad20fd5$0$26308$4f793bc4@news.tdc.fi> <61d081f4-cccc-4575-927f-5c400b73ff90@k19g2000yqc.googlegroups.com> <4ad23819$0$6256$4f793bc4@news.tdc.fi> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1255391076 2589 69.95.181.76 (12 Oct 2009 23:44:36 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 12 Oct 2009 23:44:36 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Response Xref: g2news2.google.com comp.lang.ada:8688 Date: 2009-10-12T18:42:56-05:00 List-Id: "Niklas Holsti" wrote in message news:4ad23819$0$6256$4f793bc4@news.tdc.fi... ... > Did you read about the package Ada.Tags (RM 3.9)? There is a generic > function Ada.Tags.Generic_Dispatching_Constructor that takes a tag as > parameter and creates an object with that tag, but I don't hink there is > any way to find the tags for all types in a given derivation class. So > even with Ada.Tags.Generic_Dispatching_Constructor your program still has > to register the types, or their tags, or a prototype object of each type, > to create the program-accessible set of types/tags that can be in the > graph. > > Perhaps some expert can explain why this reflection capability (find tags > for all derived types in a class) was not included in Ada.Tags? Perhaps > because Ada run-time systems do not need such a function for their own > purposes? I think that would be impossible in general, for the same reason that the rules about what tags are returned from calls to Internal_Tag are mostly written with "may". The problem is that tagged types can be created and cease to exist asychronously with respect to a call to a function in Ada.Tags. (For instance, if another task creates a tagged type by calling a subprogram with such a type declaration.) The model of Ada.Tags is that is can be implemented either with a mostly static data structure (created at link-time) or with a fully dynamic structure. In the latter case, complex locking would be required to ensure any particular (useful) answer for one of these functions. In the former case, something similar to the dynamic structure (and locking) would be required to avoid returning non-existent tags. It was felt that such requirements would add a lot of complication and runtime cost to the implementation of this package without a corresponding benefit. Finally, to actually implement some way to determine all of the tags of a particular class would require either a brute force search of all tags (very slow) or some complex additional data structures. (Remember that *every* tagged type and subtype has a corresponding 'Class, so this structure could get very large if you are using software that defines a lot of tagged types as Claw does.) The only language requirement is that each tagged type is connected to its immediate parent (in order to check type conversions), anything else further would be needed only to implement your proposed function. Even a list of all tags is not required to implement the language (although you may have a way to get it depending on your Ada.Tags implementation). Randy.