D component programming is a joke (Was: Re: Component programming)
Andre Artus
andre.artus at gmail.com
Sat Aug 3 08:56:32 PDT 2013
On Saturday, 3 August 2013 at 13:46:38 UTC, David Nadlinger wrote:
> On Saturday, 3 August 2013 at 13:35:56 UTC, Andre Artus wrote:
>> import std.stdio;
>> import std.algorithm;
>> void main()
>> {
>> auto values = [ 1, 2, 3, 4, 5 ];
>> writeln(values
>> .map!(a => a * 10)
>> .map!(a => a / 3)
>> .filter!(a => !(a % 2)));
>> }
>>
>> As stated this implies 3 separate traversals of the list (or
>> array to be specific) which is what a naïve implementation
>> would do.
>
> In this example, no, as all involved ranges are evaluated
> lazily. (I see your general point, though.)
>
> David
I probably could have worded it better: I did not intend to imply
that D follows the naïve implementation suggested. What I meant
is that, on the face of it, given typical textbook
implementations of map and filter you would be iterating 3
separate times. To be clear I don't know of any serious
implementations of these algorithms that do not address this in
some way.
More information about the Digitalmars-d
mailing list