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!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Generics vs. O-O? Date: Fri, 2 Aug 2013 16:09:46 +0200 Organization: cbb software GmbH Message-ID: <1so729qnkrrj2.ztrxvmlw6cb7.dlg@40tude.net> References: <6238c325-79c5-4537-ba55-2800110dc6df@googlegroups.com> <1wugpqyea6s39$.e2e8eshup5wn$.dlg@40tude.net> <51fadf40$0$6557$9b4e6d93@newsspool4.arcor-online.net> <15qso6tlt3uf1.h45wqc019b00$.dlg@40tude.net> <51fb80d8$0$6561$9b4e6d93@newsspool4.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: IenaDxMXK2hi7fvYcb+MlQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: 8bit 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: 4275 Xref: number.nntp.dca.giganews.com comp.lang.ada:182813 Date: 2013-08-02T16:09:46+02:00 List-Id: On Fri, 02 Aug 2013 11:50:15 +0200, Georg Bauhaus wrote: > Translating to Ada, and with reference to generic formal types, I can > indicate a category of types. There are no formal classes. Whatever. >> Regarding your example the class you used is one created outside the >> generics. It is good that Ada 95 allowed this, but it does not change the >> nature of the language of formal generic specifications. > > View 1: > > The nature of formal generic specifications is not one whose > instantiations will produce typed instances, because the latter > is not defined, or intended, in Ada. In a different theory, > things will appear differently. > > View 2: > > Not all generic formals allow indicating the "formal classes" > you find important WRT "belonging", but don't care to say what > a "formal class" is, or what "belonging" might mean WRT outreach > and"verifiable substitutability". I don't understand what you are trying to say here. > For example, a formal type may be one that has T as an ancestor, > T giving enough of verifiable information such that each > instance specifies sets of values that objects will assume > as a consequence of certain operations. If this is a proper class already there is no need to introduce a formal generic class for it. Generic classes are useful when they cannot be spelt by regular means. Generics are all about patching deficiencies of the type system. With the type system brought in order, you will need no generics. >> Parametric polymorphism of generics is way too loose, because it basically >> untyped. Worse is that it is any useful so long it remains untyped. Once >> you try to put types on it, it will be as "inconvenient" as any type >> system, while keeping all disadvantages of being strictly compile-time. > > If something *is* known at compile time, but *could* be different for > a different compilation, There is only one compilation of the program. Each compilation produces another program. > Choosing generics can remove the disadvantages of the unneeded "much" > (πολύς, polys). Simple generics can reduce complexity by removing the > overhead of polymorphic dummy parameters of a single, specific type. Removing parameter in which sense? Compare removing parameter of sine as an example (in order to reduce complexity of course). The result is a different object, a number. Function is not number. If you can reduce generics to non-generics it is no generics. Good riddance. > For example, if > you'd want a callback to be passed somewhere. Then, dismissing generics > might entail the introduction of one level of indirection (subprogram > pointer), There is no need in using pointers in order to achieve downward closures. It was a kludge of Ada 95 design. Generics is a kludge of Ada 83 design. I always prefer proper objects with a dispatching operation over closures (callbacks), because an object explicitly encapsulates state while the closure gather everything visible in the context. It is for sloppy programming style barely reconcilable with Ada. Yet another language design problem that there is no simple way to declare such singleton types in Ada. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de