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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Generators/coroutines in future Ada? Date: Tue, 11 Jul 2017 11:42:54 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 11 Jul 2017 09:39:05 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="83d22265d39091c2ac74272df395981d"; logging-data="22436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MXqRtyHVqg08kO6UYmPIr" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: Content-Language: fr Cancel-Lock: sha1:KRGlBUc+Eqz4NBVmpefyu0AdTWg= Xref: news.eternal-september.org comp.lang.ada:47352 Date: 2017-07-11T11:42:54+02:00 List-Id: Le 10/07/2017 à 15:38, Victor Porton a écrit : > But AFAIK Ada does not support closures. > > Are closures really needed to implement generators? > > It is nearly impossible to add closures to Ada, right? Taking the example from Wikipedia: function startAt(x) function incrementBy(y) return x + y return incrementBy variable closure1 = startAt(1) variable closure2 = startAt(5) This could be written as: generic Start_Value : Integer function Increment_By (X : integer) return Integer; function Closure1 is new Increment_By (1); function Closure2 is new Increment_By (5); ---- 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... 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". 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. -- 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