Linq and the like

Paulo Pinto pjmlp at progtools.org
Mon Mar 18 01:18:39 PDT 2013


On Sunday, 3 February 2008 at 12:25:17 UTC, Michiel Helvensteijn 
wrote:
> bearophile wrote:
>
>> LINQ (and its future parallel extensions), with its additional 
>> syntax, may
>> be a good thing to add to D:
>>
> http://www.moserware.com/2008/02/for-loops-using-i-i-enumerators-or-none.html
>> 
>> You can use the same syntax to simplify parallel code, DB 
>> access code,
>> etc.
>
> Can't D already do this?
>
> It has lazy evaluation of function literals, so the container 
> class just has
> to implement the count method.
>
> Even C++ can do this, though it looks more messy.
>
> Anyway, I disagree with the author about (at least) two things.
>
> * I am one of those people that use the pre-increment operator 
> in for-loops.
> I know it doesn't improve performance for integers, but it does 
> for
> iterators. So I just use it everywhere for consistency.
>
> * While I agree that when a foreach-loop is possible, you 
> should use it, it
> can never completely replace the for-loop, because it is simply 
> less
> powerful. Any number of sorting/searching algorithms still need 
> for-loops.

Really?!

for loops can be easily replaced by functional alternatives 
map/reduce.

With tail call optimizations you can even replace them by 
recursive calls without performance loss.

--
Paulo



More information about the Digitalmars-d mailing list