Ruby-style "each" in D?
w0rp
devw0rp at gmail.com
Thu Mar 20 05:32:48 PDT 2014
'each' sounds like a good idea for supporting component
programming a little more. As bearophile as already stated, you
can do something like this...
someRange.filter!foo.frobulate.each!doSomethingWithIt;
For Walter's question about parallel execution, I imagine
something like this.
// std.parallelism parallel function here.
someRange.whatever.parallel(numberOfUnits).each!doSomething
Basically it just removes a little foreach boilerplate. I don't
think the implementation needs to be much more complicated than
what Andrei wrote already, I would just pull that pretty much
as-is.
I also don't think an argument like "you can already do this with
foreach" is valid. You don't *have* to use it, and some people
might like it. I know I would appreciate having it in
std.algorithm. (I'm kind of a range fanboy.)
More information about the Digitalmars-d
mailing list