Impressed
Sean Kelly
sean at invisibleduck.org
Fri Jul 27 08:14:17 PDT 2012
On Jul 27, 2012, at 8:05 AM, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> On 7/27/12 9:10 AM, Stuart wrote:
>> On Friday, 27 July 2012 at 03:00:25 UTC, Brad Anderson wrote:
>>>
>>> D equivalent: iota(0, int.max, 2).map!(a => /* do something with even
>>> numbers */)();
>>
>> I think you're missing the point. The purpose isn't to generate a
>> sequence of numbers, but to illustrate how the Yield keyword is used in
>> VB.NET. Sure, getting a sequence of numbers may be straightforward, but
>> what about a lazy-populated list of all files on a computer? That can be
>> done using Yield - and more importantly, WRITTEN like a normal
>> synchronous function. Let's see you do that with map.
>
> I think it's fair to say yield makes some things easier to do than ranges, and ranges makes some other things easier to do than yield. Of course, ideally you'd have both, but for the time being we don't have yield.
core.thread.Fiber has yield and has been used as the basis for this style of iterator. See Mikola Lysenko's talk from the D conference a few years ago.
More information about the Digitalmars-d
mailing list