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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6d3086ecdb136e X-Google-Attributes: gid103376,public From: Jon S Anthony Subject: Re: Runtime object type determination/ runtime generic instantiation Date: 1997/11/08 Message-ID: #1/1 X-Deja-AN: 287984572 Distribution: world References: <34626166.D12266B@mindspring.com> Organization: PSINet Newsgroups: comp.lang.ada Date: 1997-11-08T00:00:00+00:00 List-Id: Anthony Jenkins writes: > The package I have to create is one for (un)directed graphs, where the > vertices can represent numbers, characters or strings (I'm thinking more > generically than these 3 types so I can possibly use it later) where the > node value type is given in a file. Am I looking at this wrong? I'm It _seems_ like you certainly are looking at it "wrong". Since you are already dealing with a higher level structure (the nodes), why don't you create a hierarchy of these? Which would also be incrementally extensible, dynamically dispatchable, etc. Here's a basic hack: type Node_Type is abstract tagged private; -- or better yet, limited private -- all the basic operations. Could be abstract as well or a mix. ... type Number_Node_Type is abstract new Node_Type; ... all the common number operations... ... type Real_Number_Node_Type is new Number_Node_Type with private; ... type Integer_Number_Node_Type is new Number_Node_Type with private; -- or you can flip these around and derive one from the other -- depending on your point of view. ... -- For example, here's a similar situation where strings -- come from characters... -- type Character_Node_Type is new Node_Type with private; ... type String_Node_Type is new Character_Node_Type with private; and so on ... /Jon -- Jon Anthony Synquiry Technologies, Ltd., Belmont, MA 02178, 617.484.3383 "Nightmares - Ha! The way my life's been going lately, Who'd notice?" -- Londo Mollari