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 Path: g2news2.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!fi.sn.net!newsfeed1.tdcnet.fi!news.song.fi!not-for-mail Date: Sun, 11 Oct 2009 22:54:34 +0300 From: Niklas Holsti Organization: Tidorum Ltd User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Runtime type selection References: <2c15c8a6-b555-4d08-8fe6-f77cb207e7a6@k33g2000yqa.googlegroups.com> <4ad20fd5$0$26308$4f793bc4@news.tdc.fi> <61d081f4-cccc-4575-927f-5c400b73ff90@k19g2000yqc.googlegroups.com> In-Reply-To: <61d081f4-cccc-4575-927f-5c400b73ff90@k19g2000yqc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4ad23819$0$6256$4f793bc4@news.tdc.fi> NNTP-Posting-Host: 81.17.205.61 X-Trace: 1255290905 news.tdc.fi 6256 81.17.205.61:49112 X-Complaints-To: abuse@tdcnet.fi Xref: g2news2.google.com comp.lang.ada:8674 Date: 2009-10-11T22:54:34+03:00 List-Id: xorque wrote: > On Oct 11, 5:02 pm, Niklas Holsti > wrote: >> Keep a list or array of (accesses to) a factory function for each >> possible (derived) type. > > 'Lo, > > That does sound like the sort of thing I'd have done in C. Yes. Ada makes it easier since you can use elaboration-time statement blocks in package bodies to register stuff. > I still > have a nagging sensation that Ada actually provides other means to > do this based on such things as the 'Tag attribute. 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? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .