On Sun, Jul 18, 2010 at 06:19, Jonathan M Davis wrote: ***** I think that the problem with find() is not so much find() but it's documentation. In all honesty, anything with a return type like FindResult!(Range, Ranges) is going to scare people off. *****
What should be done (in a perfect world) is to have a simplified signature that can become the complete signature on a click auto find!()(haystack, needles) => FindResult!(etc. ... the empty !() being a cue that it's a template function and that there is more to it that meets the eye. (edit: crap, you said it afterwards. I should not reply hours after first reading a message) ***** If anything, I've been more interested in canFind() and until() being made to match up with find(). I'd like to be able to give them both pretty much the same arguments and then get the bool from canFind() and the range that find() would have walked over in the case of until(). A function which gave you both the range that until() would have given you as well as the one which find() would have given you would be nice as well. I previously opened a bug with thoughts along those lines: http://d.puremagic.com/issues/show_bug.cgi?id=3888 ***** Ah, these are called takeWhile, dropWhile and span, in Haskell and other sequence-heavy languages. Or splitBy, cutAt, etc. Quite handy to have, I agree std.algorithm should have them. But then, it's huge module already. ***** In any case, I think that find() itself is more or less fine from a usage standpoint. It's the docs that need help. The other thing would be to add a lot more examples. That would be a big boon for a lot of std.algorithm functions. They're not necessarily hard to use, and the examples show it much more clearly than the signatures often do. ***** I sometimes dream of a complement to Phobos that would demonstrate its use, either by providing lots of examples for each function or by taking a module and tackling a task with it. Obviously, as both a complement to Phobos and a way to demo-nstrate D, it should be called Deimos, the second moon of Mars, Phobos' sibling. Now, the Deimos Project, that's some cool name, if I may say so. But I guess the wiki already does this. Philippe