[Submission] D Slices

eles eles at eles.com
Tue May 31 12:55:50 PDT 2011


== Quote from Andrej Mitrovic (andrej.mitrovich at gmail.com)'s article
> Quite frankly I don't give a damn about for loops because I hardly
use
> them. Whenever I can, I use foreach, and if I get stuck and think
that
> foreach can't be used I rather think twice and consider to do a
small
> redesign of my code rather than start using ancient for loops.

Foreach is an abstraction for... for. When it comes to abstractions,
please read this paper: http://www.joelonsoftware.com/articles/
LeakyAbstractions.html

I hate giving links but sometimes it must. You can live in a world of
abstractions. But what when things no longer work? What if foreach
does not work and the nice world of abstractions gets stucked?

The simple truth is that the for loops are the base on which
abstractions like foreach are constructed. And if abstractions are
leaky... well, then.

I don't
> want to deal with these silly signed/unsigned/overflow issues at
all.
> Foreach for the win. Foreach and lockstep for the double win.
> In fact, from what my *.d searches tell me, most of my for loops
come
> from C relics of code which I've translated into D.
> But I don't do scientific computing, so that's just me. :)

You are not solving the problem. You are hiding it.
I also do *a lot* of scientific computing. Processing arrays are the
daily basis of my work.



More information about the Digitalmars-d mailing list