comp.lang.ada
 help / color / mirror / Atom feed
* Dynamic Instantiation in Ada95 ?
@ 1998-04-15  0:00 Matthias Oltmanns
  1998-04-15  0:00 ` Tucker Taft
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthias Oltmanns @ 1998-04-15  0:00 UTC (permalink / raw)



Hi all,

I would like to implement a kind of runtime instantiation for class-wide
types, where the concrete type is not known
at compile time.
I've searched for a method in exact that way as S'Class'Input is working.
S'Class'Input first reads the external tag name from a stream and than
makes a dispatching call to the appropriate S'Input method.

Example:
...
    type Base is tagged with null record;

    function Create return Base;
    --
    function Create_Dynamic (Tag_Name : String) return Base'Class;
 ...
   << Some type-extensions for the type Base >>
...

I would like to implement the function as follows:

   function Create_Dynamic (Tag_Name : String) return Base'Class is
     T : Ada.Tags.Tag := Ada.Tags.Internal_Tag (Tag_Name);
    begin
        return <<dispatching call to Create using tag T>>;
    end Create_Dynamic;

Is there a way to do that? I've found only some dirty hacks, using
unchecked_deallocation , for T'Address use ...
and so on.

I'am interresting for a more portable approach. Any suggestions?

Matthias Oltmanns,  Email: Matthias.Oltmanns@so.sema.de, Phone: +49 4421
802 207, Fax: +49 4421 802 444,
SEMA GROUP GmbH Wilhelmshaven (Germany) - Special Systems Division -




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-04-17  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-15  0:00 Dynamic Instantiation in Ada95 ? Matthias Oltmanns
1998-04-15  0:00 ` Tucker Taft
1998-04-16  0:00 ` Stephen Leake
1998-04-16  0:00   ` Matthew Heaney
1998-04-17  0:00 ` Robert Dewar

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