[Issue 3923] New: std.algorithm.find is too much hard to understand

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 10 06:23:11 PST 2010


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

           Summary: std.algorithm.find is too much hard to understand
           Product: D
           Version: 2.041
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-03-10 06:23:10 PST ---
The find() of std.algorithm is too much hard to understand. I can't understand
how to use it and what it returns.

It's even hard to understand this in the docs page:

FindResult!(Range,Ranges) find(alias pred = "a == b", Range, Ranges...)(Range
haystack, Ranges needles);
struct BoyerMooreFinder(alias pred,Range);
BoyerMooreFinder!(binaryFun!(pred),Range) boyerMooreFinder(alias pred = "a ==
b", Range)(Range needle); 

Such functions must be simple enough for normal people to use. If you need more
than 10 minutes to understand how to use something as simple as a "find", then
the library API is badly designed. It's not a limit of my brain, it's a problem
in the library design.

If I need to know that the substring "foo" is present in "abfoobar" in Python I
write:

"foo" in "abfoobar"

This covers 85%+ of the cases in normal programs.

-- 
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