Impressed

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 27 12:03:21 PDT 2012


On Friday, July 27, 2012 20:52:37 Stuart wrote:
> I think perhaps you are confusing two different meanings of
> yield. I am not talking about threading. The VB.NET "yield" and
> "iterator" keywords can be used just as well in a single-threaded
> application.

>From what you've been saying, it sounds like yield is probably the equivalent 
of declaring a range type in place and using it, which is quite doable but is 
somewhat more verbose. In most basic cases though, a function probably already 
exists in std.algorithm that will let you do what you want to do by only 
providing a lambda function rather than a new range. And the more complex 
cases have enough implementation that the boilerplate range type declarations 
are small in comparison. Maybe we _should_ look at providing a better 
mechanism for creating range types in-place at some point, but what we have - 
particularly with std.algorithm - is already quite powerful, and I rarely see 
the need (if ever) to declare a range in-place.

Regardless, with where D is right now, there's no way that such a feature 
would be added the language itself any time soon. It's probably possible to 
provide a library solution though, where you just give lambda functions for 
empty, front, and popFront, which would make creating a basic input range in 
place quite easy.

- Jonathan M Davis


More information about the Digitalmars-d mailing list