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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Generators/coroutines in future Ada? Date: Wed, 12 Jul 2017 20:39:07 +0300 Organization: Aioe.org NNTP Server Message-ID: References: <87pod8dy5j.fsf@nightsong.com> <87o9sp4m61.fsf@nightsong.com> NNTP-Posting-Host: i1vc24+njmQErCAdcylhNA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:47387 Date: 2017-07-12T20:39:07+03:00 List-Id: Paul Rubin wrote: > Victor Porton writes: >> every algorithm can be done with OOP... >> So the question is not whether an equivalent algorithm can be coded, but >> whether it can be done naturally and explicitly. > > There is a fairly natural bijection between OOP and closures, if that's > what you're asking. I am asking for the easier (smaller code) side of the bijection. That generator functions with "yield" (in Python sense) can be replaced with another side of the bijection does not necessarily mean that we should use the more long code side of the bijection, when we have shorter and probably easier to understand (and thus probably more reliable) code at the another side of the bijection. >> Is it possible to add explicit generator functions to Ada? > > I don't know if Ada has syntactic support for traversing a container by > calling some method on it. C++ and Python both have that and I doubt it > would be a big deal to add it to Ada if it's not there already. I am not about syntactic support for traversing a container by calling some method of it (certainly both Ada, Python, and C++) do support it. I am about iterators coded as a function with "yield" construct (in Python sense). I am not about iterators coded with plain OOP without using "yield" or a similar construct. -- Victor Porton - http://portonvictor.org