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.99.96.209 with SMTP id u200mr1318277pgb.28.1499838131494; Tue, 11 Jul 2017 22:42:11 -0700 (PDT) X-Received: by 10.36.83.73 with SMTP id n70mr35743itb.0.1499838131453; Tue, 11 Jul 2017 22:42:11 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!188no104412itx.0!news-out.google.com!196ni26itl.0!nntp.google.com!v202no107738itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 11 Jul 2017 22:42:11 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=62.235.158.22; posting-account=nuF4hQoAAADjc2KKS1rOkzxWWEmaDrvx NNTP-Posting-Host: 62.235.158.22 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0260f40d-0737-4d92-a2e3-bcada4cbcb20@googlegroups.com> Subject: Re: Generators/coroutines in future Ada? From: darkestkhan Injection-Date: Wed, 12 Jul 2017 05:42:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47369 Date: 2017-07-11T22:42:11-07:00 List-Id: On Tuesday, July 11, 2017 at 9:42:59 AM UTC, J-P. Rosen wrote: > Le 10/07/2017 =C3=A0 15:38, Victor Porton a =C3=A9crit : > > But AFAIK Ada does not support closures. > >=20 > > Are closures really needed to implement generators? > >=20 > > It is nearly impossible to add closures to Ada, right? >=20 > Taking the example from Wikipedia: >=20 > function startAt(x) > function incrementBy(y) > return x + y > return incrementBy >=20 > variable closure1 =3D startAt(1) > variable closure2 =3D startAt(5) >=20 > This could be written as: > generic > Start_Value : Integer > function Increment_By (X : integer) return Integer; >=20 > function Closure1 is new Increment_By (1); > function Closure2 is new Increment_By (5); >=20 > ---- > I can hear you saying that "generics are a poor man's workaround for the > lack of closure", to which I respond that closures are a limited > workaround for the lack of the more general concept of generic... >=20 > TBH, I don't think there is any value in the kind of discussion that > starts with "Language X is lacking feature A from language Y". >=20 > Express a problem in language Y, let people provide their solution in > language X, and then we can discuss the merits of each solution, given > some quality criteria. Note that sometimes, criteria can be at odds; > f.e., people nowadays value ease of writing and flexibility very much, > but these are quite opposed to safety, readability, and long term > maintenance which form the basic requirements of Ada. >=20 > --=20 > J-P. Rosen > Adalog > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 > http://www.adalog.fr Other ways in which this can be done (beside generic package with state): - task - protected object - additional argument of [tagged] limited type Likely some other ways are possible. I just don't see what is the point of = special construct for generators when we got at least 4 ways to do it.