std.range: Order of arguments unluckily chosen?

so so at so.so
Mon Jun 6 11:10:58 PDT 2011


> I think it is about readability of nested statements:
>
> take(10,stride(2,cycle([3,2,5,3])));
>
> vs.
>
> [3,2,5,3].cycle().stride(2).take(10);
>
> The first one is: "Take 10 of every 2nd element of cyclic [3,2,5,3,...].
> The second one is: "Start with [3,2,5,3]. Then cycle that. Then only  
> look at every
> 2nd element of that. Finally, take 10 elements out of the resulting  
> range."

Thanks, this alone makes me realize the need for UFCS. Until now i was  
thinking it is just about taste, look, that some people like the OO way.

> The second version writes the actions in the order they are performed,  
> while the
> functional way is more like what you'd get if you had to describe the  
> entire
> process in a single sentence. It also reduces nesting of parentheses. I  
> am fine
> with both. But I dislike
>
> take(stride(cycle([3,2,5,3]),2),10);

I agree.


More information about the Digitalmars-d mailing list