Am 16.11.2012 14:18, schrieb monarch_dodra: > I'd like to get a green light to undeprecate "indexOf". > > The rationale for the original deprecation is that it was superseded by > "countUntil", which also > works on forward ranges (indexOf implies, by name, that it only operates on > RA). > > There is just one problem: > "日本語".indexOf(本) => 3 > "日本語".countUntil(本) => 1 > > As you can see, when operating on UTF strings, the (expected) result of > countUntil is not the same > as that of indexOf. > > countUntil is currently bugged, in the sense that it will return the index in > the string (as opposed > to the count of popFront's). However, this needs fixing. If users migrate > countUntil to indexOf > without thinking, it could lead to some terrible, terrible bugs. > > Phobos was migrated. I found the issue in datetime (which is "OK", since date > is ASCII), but also in > std.path, which is NOT OK. At all. Who knows what's out there in the nature? > > ------- > So yeah, I want to un-deprecate indexOf, and re-document it as working only > on RA. > > Can I get some Yays or Nays?
Fully agree about the fix of countUntil - I can imagine that there is a non-trivial amount of code that blindly uses countUntil instead of indexOf because of the deprecation (I know I also did this before). But there is still std.string.indexOf, which should do the right thing here... wait, no, that one also screws up and returns based on the ASCII state of the search character! However this all is fixed, it will probably cause a good amount of breakage, but there is no way around it. Btw. is 'string' actually considered a RA range? After all it provides no useful invariants apart from str[0] == str.front - str[1] could be different from str.popFront(); str.front.
