comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generics vs. O-O?
Date: Thu, 1 Aug 2013 21:24:57 +0200
Date: 2013-08-01T21:24:57+02:00	[thread overview]
Message-ID: <1wugpqyea6s39$.e2e8eshup5wn$.dlg@40tude.net> (raw)
In-Reply-To: 6238c325-79c5-4537-ba55-2800110dc6df@googlegroups.com

On Thu, 1 Aug 2013 07:45:13 -0700 (PDT), Eryndlia Mavourneen wrote:

> I need to write a template package to be used by several different
> mechanisms (units).  The question is, "What are the trade-offs between
> using a generic package as the template and using a package-as-class
> containing O-O code?"  I am aware that generics can take more time to
> compile; however, I am more interested in run-time effects.

I don't really understand the question.
 
> Can anyone provide a short summary?

1. Both generics and OO (tagged types) represent polymorphism.

2. Generics is so-called parametric or static polymorphism.

3. Tagged types is dynamic polymorphism.

4. Beyond "generic programming" generics are not restricted to only types.
In Ada one can have generic objects, operations, anything that can be put
into a generic unit.

5. Considering run-time effects generics obviously have none because it is
static polymorphism.

6. Generic classes are implicit and have no objects. Tagged classes are
explicit and may have class-wide objects.

7. Formal generic types of Ada are weakly typed. Matching is by structure.
User-defined generic types (ADTs) are not supported. User-defined
operations on formal types are not supported. The language of formal
generic parameters is somewhere between FORTRAN-IV and K&R C.

8. Tagged types are fully integrated into Ada's type system. Still some
classes of Ada types are not proper tagged classes, e,g, numbers, tasks
etc.

9. Generic units are basically non-testable. Substitutability issues are
difficult to verify because of 7.

10. For tagged types substitutability is a problem as well.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2013-08-01 19:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 14:45 Generics vs. O-O? Eryndlia Mavourneen
2013-08-01 19:24 ` Dmitry A. Kazakov [this message]
2013-08-01 19:52   ` Eryndlia Mavourneen
2013-08-01 20:14     ` sbelmont700
2013-08-01 23:35       ` Yannick Duchêne (Hibou57)
2013-08-01 20:10   ` optikos
2013-08-01 20:26     ` Dmitry A. Kazakov
2013-08-01 20:35     ` Jeffrey Carter
2013-08-01 21:22     ` Bill Findlay
2013-08-01 23:38     ` Yannick Duchêne (Hibou57)
2013-08-01 22:20   ` Georg Bauhaus
2013-08-02  8:11     ` Dmitry A. Kazakov
2013-08-02  9:50       ` Georg Bauhaus
2013-08-02 14:09         ` Dmitry A. Kazakov
2013-08-02 15:08           ` Shark8
2013-08-02 15:36             ` Alan Jump
2013-08-02 17:00               ` Jeffrey Carter
2013-08-02 17:51               ` Dmitry A. Kazakov
2013-08-02 18:06                 ` Alan Jump
2013-08-02 19:08                   ` Dmitry A. Kazakov
2013-08-02 16:15             ` Dmitry A. Kazakov
2013-08-03  0:04       ` Yannick Duchêne (Hibou57)
2013-08-03  7:35         ` Georg Bauhaus
2013-08-03  8:57           ` Dmitry A. Kazakov
replies disabled

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