comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@dr_no.mitre.org (Robert I. Eachus)
Subject: Re: Classes vs Tagged Types - Terminology
Date: Wed, 31 Mar 1993 20:46:38 GMT
Date: 1993-03-31T20:46:38+00:00	[thread overview]
Message-ID: <EACHUS.93Mar31154638@dr_no.mitre.org> (raw)
In-Reply-To: stt@spock.camb.inmet.com's message of Tue, 30 Mar 1993 14:34:46 GMT

In article <1993Mar30.143446.20879@inmet.camb.inmet.com> stt@spock.camb.inmet.com (Tucker Taft) writes:

  > Good point.  However, a compile-time parameterized 
  > abstraction, as embodied by an Ada 83 generic, 
  > cannot provide the dynamic flexibility of the run-time
  > polymorphism of object-oriented languages, where each object
  > at run-time identifies its own underlying type.  For example,
  > try creating a heterogeneous linked list using Ada 83 generics.
  > You might be able to do it (I always hesitate claiming you *can't*
  > do something with generics with Robert Eachus around ;-), 
  > but it will be a lot of work and the result will probably 
  > not be as "user friendly."

     Right way to bet, but you didn't take it far enough. :-)

     Seriously, it is very easy (well, easy for me anyway) to write a
polymorphic list package in Ada 83, you can even have objects and
parameters which would be of type T'CLASS in Ada 9X.  The only problem
is that you have to "hand write" the dispatching which occurs when you
actually try to do something with a value of a class-wide object.
However operations on class wide values whose return values are not of
a specific element type are no problem.

     I could post a toy example here, but if anyone is interested I
wrote something very similar for processing DIANA trees.  (It didn't
even use generics.)  Since most of the dispatching was in the body of
the package (and generated by a tool, I'm no glutton for punishment)
it reduced the size of the code using the package by an order of
magnitude or so over a non-abstract type.

     Don't get me wrong, the addition of tagged types in Ada 9X will
make a lot of things easier, and will provide a lot of functionality
not in Ada 83.  It's just that polymorphic data structures have always
been "in there."  Using them has just never become a normal part of
the Ada culture.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...



  parent reply	other threads:[~1993-03-31 20:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-22 11:46 Classes vs Tagged Types - Terminology Charles Lindsey
1993-03-24  7:42 ` Richard A. O'Keefe
1993-03-25 15:56   ` Tucker Taft
1993-03-26 11:02     ` Stephen J Bevan
1993-03-30 14:34       ` Tucker Taft
1993-03-31 16:21         ` Stephen J Bevan
1993-03-31 20:46         ` Robert I. Eachus [this message]
1993-03-24  8:58 ` Robb Nebbe
1993-03-25  0:15   ` David Emery
1993-03-29  9:26     ` Robb Nebbe
  -- strict thread matches above, loose matches on Subject: below --
1993-04-05 15:54 John Goodsen
1993-04-05 23:04 ` Mark A Biggar
1993-04-06 16:36 Harry Koehnemann
1993-04-06 16:46 mcsun!julienas!newsserver!geant!bruniau
1993-04-07 13:49 pipex!uknet!warwick!zaphod.crihan.fr!univ-lyon1.fr!scsing.switch.ch!sicsu
replies disabled

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