From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Generators/coroutines in future Ada?
Date: Wed, 12 Jul 2017 22:49:20 +0200
Date: 2017-07-12T22:49:20+02:00 [thread overview]
Message-ID: <ok61p7$fcn$1@dont-email.me> (raw)
In-Reply-To: <ok4jda$1dud$1@gioia.aioe.org>
On 12.07.17 09:34, Dmitry A. Kazakov wrote:
>>> I don't understand what is wrong with:
>>>
>>> type Stateful is limited private;
>>> function Generate (X : not null access Stateful) return Things;
>>
>> Arguably, first, a "function" lacks query/command separation:
>>
>> type Stateful is limited interface;
>> function Current (x : Stateful) return Thing; -- (*)
>> procedure Next (x : in out Stateful);
>
> I don't understand this example. Why Next cannot be a part of Current? Example:
>
> X := Stack.Pop;
It didn't say it can't be. (Without query/command separation,
one needs access parameters using most versions of Ada, though,
because then a function (query) is not really allowed to modify
_its_ parameters, unlike a procedure (command) that has an in out
parameter.)
Assume that the language has special generator syntax, e.g.:
while X of Stack with 0 < X and X < 10 loop
This is to mean that generating a value happens once per iteration,
binding the result to the X before *of* and then evaluating the
condition. Stack being a Stateful, it has the prim ops needed.
If X, still a generator, were instead to be repeatedly evaluated,
as in
while 0 < X and X < 10 loop
then it isn't clear how many values will be generated if,
under the hood, the expression entails evaluating
0 <Stack.Pop and Stack.Pop < 10.
What about optimizing? Nothing new.
At first sight, this pattern can be expressed by making
a single assignment which has been working even before Ada 83:
X : Value_Type := Stack.Pop;
while 0 < X and X < 10 loop
But this pattern can only lead to emulating any number of
particular generator-like objects, not to generators:
no special types, no syntax, hence no support from the compiler.
Note that this argument emphasizes the use of a generator,
not the construct that furnishes it.
next prev parent reply other threads:[~2017-07-12 20:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-09 20:19 Generators/coroutines in future Ada? Victor Porton
2017-07-09 21:28 ` Dennis Lee Bieber
2017-07-09 23:56 ` Victor Porton
2017-07-10 7:33 ` Dmitry A. Kazakov
2017-07-10 13:38 ` Victor Porton
2017-07-10 17:01 ` Paul Rubin
2017-07-10 21:24 ` Victor Porton
2017-07-12 17:09 ` Paul Rubin
2017-07-12 17:39 ` Victor Porton
2017-07-13 6:35 ` Paul Rubin
2017-07-11 9:42 ` J-P. Rosen
2017-07-11 12:52 ` Victor Porton
2017-07-11 13:01 ` Victor Porton
2017-07-11 13:26 ` J-P. Rosen
2017-07-11 16:04 ` Dennis Lee Bieber
2017-07-11 16:59 ` Dmitry A. Kazakov
2017-07-11 19:52 ` Pascal Obry
2017-07-11 20:18 ` Dmitry A. Kazakov
2017-07-11 18:36 ` Victor Porton
2017-07-11 19:22 ` J-P. Rosen
2017-07-11 20:25 ` Dmitry A. Kazakov
2017-07-11 23:19 ` Victor Porton
2017-07-12 4:54 ` J-P. Rosen
2017-07-12 13:07 ` Victor Porton
2017-07-12 13:38 ` Dmitry A. Kazakov
2017-07-12 5:35 ` Randy Brukardt
2017-07-12 7:27 ` Dmitry A. Kazakov
2017-07-12 22:47 ` Shark8
2017-07-16 13:11 ` Robert Eachus
2017-07-17 23:54 ` Randy Brukardt
2017-07-18 7:38 ` Dmitry A. Kazakov
2017-07-12 7:19 ` Dmitry A. Kazakov
2017-07-12 6:35 ` G.B.
2017-07-12 7:34 ` Dmitry A. Kazakov
2017-07-12 20:49 ` G.B. [this message]
2017-07-13 8:18 ` Dmitry A. Kazakov
2017-07-12 17:34 ` Paul Rubin
2017-07-11 19:27 ` Simon Wright
2017-07-12 5:42 ` darkestkhan
2017-07-12 8:57 ` Maciej Sobczak
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox