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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.180.14.72 with SMTP id n8mr1142781wic.3.1375456119210; Fri, 02 Aug 2013 08:08:39 -0700 (PDT) X-Received: by 10.50.106.50 with SMTP id gr18mr123334igb.1.1375456119034; Fri, 02 Aug 2013 08:08:39 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!g3no4710660wic.0!news-out.google.com!cc8ni6102wib.1!nntp.google.com!fx3no571457qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 2 Aug 2013 08:08:38 -0700 (PDT) In-Reply-To: <1so729qnkrrj2.ztrxvmlw6cb7.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 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> <1so729qnkrrj2.ztrxvmlw6cb7.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8bef1dc4-547b-478e-b81a-09077212f821@googlegroups.com> Subject: Re: Generics vs. O-O? From: Shark8 Injection-Date: Fri, 02 Aug 2013 15:08:39 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 3454 Xref: number.nntp.dca.giganews.com comp.lang.ada:182814 Date: 2013-08-02T08:08:38-07:00 List-Id: On Friday, August 2, 2013 8:09:46 AM UTC-6, Dmitry A. Kazakov wrote: >=20 >=20 > > 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), >=20 > 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. No, it was a well thought-out and justified feature; see the Ada83 rational= e: 12.1 Introduction Generic units are a general form of parameterized program units. As with ot= her parameterization mechanisms, the primary purpose is factorization, resu= lting in a reduction in the size of the program text while also improving m= aintainability, readability, and efficiency. Parameterization by generic units is a natural extension of subprogram para= meterization. When otherwise identical actions differ by a particular value= or variable, these actions may be encapsulated in a subprogram where the v= alue or variable appears as a parameter. Having thereby factored out the co= mmon part, the text becomes smaller and easier to read; and clerical errors= , resulting from accidental lack of identity among the copies, are eliminat= ed. Moreover, compilers can take advantage of this commonality to produce m= ore compact code. Traditional parameterization mechanisms are usually in terms of values and = variables. But the same factorization arguments apply when two otherwise id= entical program units differ by some other property, such as a type.=20 > Yet another language design > problem that there is no simple way to declare such singleton types in Ad= a. Really? In Ada 2012 I can say the following: package Test is Type K is Private; =09 J : Integer :=3D 12; =09 private use type System.address; =09 type K is new integer with TYPE_INVARIANT =3D> K'Address =3D J'Address; end test; Type K sure looks like a singleton to me.