comp.lang.ada
 help / color / mirror / Atom feed
From: boschg@cs.utwente.nl (Geert Bosch)
Subject: Re: Extending A Generic Signature Package
Date: 1997/03/21
Date: 1997-03-21T12:36:15+00:00	[thread overview]
Message-ID: <5gtvbv$1nj@pandora.cs.utwente.nl> (raw)
In-Reply-To: 5gn90o$gm1@sutton.cs.columbia.edu


Alexander V. Konstantinou (akonstan@news.cs.columbia.edu) wrote:
: OO people will tell you to use inheritance, but there is
: really no reason to pay for the overhead when your abstraction
: can be served by a compile-time check.

You shouldn't confuse using tagged types with dynamic dispatching. 
Suppose you have this situation:

   type Base is tagged record ... end record;
   procedure Op1 (X : in out Base);
   procedure Op2 (X : in out Base);

   type Extended is new Base with ...;
   procedure Op1 (X : in out Extended);
   procedure Op3 (X : in out Extended);

In this case you can just declare an object of type Extended and use
the operations Op1, Op2 and Op3 without any overhead due to dispatching. 
Dispatching occurs when you use (pointers to) class-wide types like
in the following case:

   declare
       type Object_Ptr is access all Base'Class;
      X : Object_Ptr := new Base;
   begin
      Op1 (X.all);
   end;
   
So whether a call to a primitive operation on a tagged type is dispatching or
not is determined at the call-site. I don't know why you wouldn't want to use
tagged types in your situation. The per-object space overhead shouldn't be
more than one or to pointers in most compilers. 

Regards,
   Geert




  reply	other threads:[~1997-03-21  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-17  0:00 Extending A Generic Signature Package david scott gibson
1997-03-18  0:00 ` Tucker Taft
1997-03-18  0:00   ` Alexander V. Konstantinou
1997-03-21  0:00     ` Geert Bosch [this message]
1997-03-21  0:00       ` Brian Rogoff
1997-03-22  0:00         ` Robert A Duff
1997-03-21  0:00 ` Jon S Anthony
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-22  0:00 ` Jon S Anthony
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-25  0:00 ` Jon S Anthony
replies disabled

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