Request for "indexOf" undeprecation.

Jonathan M Davis jmdavisProg at gmx.com
Fri Nov 16 13:16:49 PST 2012


On Friday, November 16, 2012 14:18:02 monarch_dodra wrote:
> Can I get some Yays or Nays?

Absolutely not.

std.algorithm.indexOf was _always_ supposed to return code points for strings. 
It's an outright bug if it ever did otherwise. It was renamed to countUntil so 
that people would not mistakingly use it on strings and think that they were 
getting an index. That's what std.string.indexOf does. Any code that relies on 
std.algorithm.indexOf or std.algorithm.countUntil returning the index of for 
strings rather than the number of code points is wrong and needs to be fixed.

Undeprecating std.algorithm.indexOf would just perpetuate the problem, and it 
makes _no_ sense for anything in std.algorithm to operate on string indexes 
anyway. std.algorithm treats all strings as ranges of dchar, and having 
anything in there operating on string indexes would violate that.

If the deprecation message needs improvement, then feel free to improve it, 
but anything which was calling std.algorithm.indexOf to get the index of a 
string was wrong to begin with.

- Jonathan M Davis


More information about the Digitalmars-d mailing list