From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Generics vs. O-O? Date: Thu, 1 Aug 2013 21:24:57 +0200 Organization: cbb software GmbH Message-ID: <1wugpqyea6s39$.e2e8eshup5wn$.dlg@40tude.net> References: <6238c325-79c5-4537-ba55-2800110dc6df@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: q/ev1P9zCVSwu+vpMGX5Tw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2702 Xref: number.nntp.dca.giganews.com comp.lang.ada:182798 Date: 2013-08-01T21:24:57+02:00 List-Id: 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