[Issue 5691] walkLength() compatible with opApply()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 16:41:51 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5691



--- Comment #8 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-03-03 16:38:57 PST ---
Honestly, whenever I see anyone discussing opApply, my first reaction is to
question why they're using it in the first place. In almost all cases, ranges
do what opApply can do, and they do it better. There _are_ a few cases where
opApply is still better (e.g. you can get indices out of opApply with foreach
but not ranges), but in most cases, opApply is unnecessary. And a lazily
iteraterable struct sounds _very_ much like it should be range.

std.range and std.algorithm are designed around ranges, not opApply. If
anything, the fact that someone needs to use opApply for something rather than
a range indicates that ranges need to be improved, not that we need to take our
range-based functions are make them work with opApply. As Andrei point out, the
added complexity would be quite large, and we definitely don't want that.
Really, if you want to use range-based stuff, you should be using ranges. And
from the little you've said about your use case, it seems like a _prime_
example of something that should be a range rather than use opApply.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list