[Issue 5201] std.string.indexOf and std.algorithm.indexOf return different things for narrow strings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 16 16:20:32 PST 2010


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



--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2010-11-16 16:19:18 PST ---
Glancing at std.string.indexOf() again, it has different parameters than
std.algorithm - dealing with case sensitivity and whatnot. It also takes a
dchar rather than a string or some variety to find the index of, which differs
from what std.algorithm does - since it uses startsWith(). Given the
differences, I'd argue in favor of just making std.algorithm.indexOf() not
working with char arrays. However, it would be nice if std.string.indexOf()
were made to work with strings rather than dchar (or in addition to it), and it
doesn't take a predicate like std.algorithm's indexOf() does, and those could
be useful.

Ultimately, I think that the two functions should be made to work more
similarly than they do on more than just what type of index that they're
returning - particularly since a _lot_ of programs are going to be importing
both std.algorithm and std.string (most of mine definitely do). Fixing the
index issue though is the highest priority in that it changes behavior based on
imports whereas the other differences are major enough to result in compilation
errors if you use the wrong one.

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