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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9e7db243dfa070d7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Do people who use Ada also use ocaml or F#? Date: Sat, 30 Oct 2010 17:12:44 +0300 Organization: Tidorum Ltd Message-ID: <8j2nesF7crU1@mid.individual.net> References: <87ocab3mir.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net slCdLqlZmUvpdpGx34VVmwoDUijsvChPkM6MmnECW+V7wIeEHr Cancel-Lock: sha1:WF8m5capC59kE1Ap9NQqiGFr2r8= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:15946 Date: 2010-10-30T17:12:44+03:00 List-Id: Yannick Duchêne (Hibou57) wrote: > Le Sat, 30 Oct 2010 14:14:52 +0200, Florian Weimer a > écrit: > >> * Yannick Duchêne (Hibou57): >> >>> Ada 2012 introduced something looking like coroutines with the yield >>> function (formally, generators), which is a famous feature of >>> functional paradigm languages (gonna be great for kinds of streams of >>> any kind of data or iterators). >> >> Is this AI05-166? I don't see how this leads to generators. > I will not believe I am the only one who expect to use it for that > purpose. This would be incredible. > I like it for iterators and every thing which is close or less close to > streams in the large. I use to talk about “coroutine” here, while the > real coroutine is more than that. But I don't mind, as I was not > expecting more. > > What I like with it, is that it allow clean separation of the behavior > and usage. You simply have one or more yield points, instead of > returning from a procedure or function and having ugly control structure > to go to the resume point when the function is invoked again. This allow > to give control where the control should be given : weither the method > is controlling or is controlled, you have the same algorithm in both > case, expressed the same way. Otherwise, a simulation of Yield simply > make every thing less clear, as half of what you write is dedicated to > this Yield simulation. I hesitate to say so, Yannick, but what you say above makes we wonder if you really know what sort of "yield" is proposed for Ada 2012. As I understand the proposed Ada 2012 Yield procedures, they are meant for low-level control of task scheduling, not as an "incremental" return statement that returns an element in an stream, for which the name "yield" is sometimes used in other languages and, in particular, for iterator-like operations. A call of the Ada 2010 Yield is simply a dispatching point at which the running (calling) task is put back into the "ready" queue(s) and a new (or the same) task is chosen for running. You can, of course, use Ada tasks to build the equivalent of coroutines, but you must then use inter-task communication methods (rendez-vous or protected objects) to transfer data between the tasks that simulate coroutines. You can do this without using the new Yield procedures, in which case normal Ada task scheduling interleaves the tasks/coroutines. The new Yield procedures would only help you to enforce a task switch when it would not necessarily occur automatically -- for example, between ready tasks of equal priority. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .