comp.lang.ada
 help / color / mirror / Atom feed
From: Jon S Anthony <jsa@synquiry.com>
Subject: Re: Runtime object type determination/ runtime generic instantiation
Date: 1997/11/08
Date: 1997-11-08T00:00:00+00:00	[thread overview]
Message-ID: <ufaffegbg9.fsf@synquiry.com> (raw)
In-Reply-To: 34626166.D12266B@mindspring.com


Anthony Jenkins <abjenkins@mindspring.com> 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




  reply	other threads:[~1997-11-08  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-06  0:00 Runtime object type determination/ runtime generic instantiation Anthony Jenkins
1997-11-08  0:00 ` Jon S Anthony [this message]
1997-11-10  0:00   ` Anthony Jenkins
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox