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: Anthony Jenkins Subject: Re: Runtime object type determination/ runtime generic instantiation Date: 1997/11/10 Message-ID: <3466D097.2B505E32@mindspring.com>#1/1 X-Deja-AN: 288838430 References: <34626166.D12266B@mindspring.com> X-Server-Date: 10 Nov 1997 09:16:22 GMT Organization: MindSpring Enterprises Newsgroups: comp.lang.ada Date: 1997-11-10T09:16:22+00:00 List-Id: Jon S Anthony wrote: > > 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 > Thanks! That *does* make a lot more sense... I wasn't thinking OO enough. Anthony Jenkins http://www.auburn.edu/~jenkian abjenkins @ mindspring , com (Death to spammers) ------------- "God is as real as I am," the old man replied. My faith was restored, for I knew Santa would never lie.