Andrei Alexandrescu wrote:
dsimcha wrote:
== Quote from Andrei Alexandrescu ([email protected])'s
article
I'm not sure what needs to be done about the combo string + algorithm.
There's quite some overlap, and also functions that have the same name
in both modules (e.g. find()), which forces you to disambiguate.
Should std.algorithm automatically recognize strings and proceed
accordingly, should it just consider them straight arrays and leave
everything else to std.string (risky!), or refuse to handle strings?
I like the idea of automatically specializing on strings, at least on
the surface.
It's less to remember for the programmer, less annoying naming
collisions, and
stuff "just works". You get your generic std.algorithm stuff when you
need it and
your more optimized/variable length character encoding stuff when you
need it
without having to explicitly specify which one you want.
Cool! So then how do I rename find, ifind, rfind, and irfind in std.string?
Andrei
Like others I think the names should be:
find -> indexOf
rfind -> lastIndexOf
but I think the declaration should look like this:
size_t indexOf (string s, dchar d, size_t start = 0)
perhaps an argument for case sensitive also:
size_t indexOf (string s, dchar d, size_t start = 0, bool caseSensitive
= true)