Request for "indexOf" undeprecation.
monarch_dodra
monarchdodra at gmail.com
Fri Nov 16 13:59:35 PST 2012
On Friday, 16 November 2012 at 21:17:00 UTC, Jonathan M Davis
wrote:
> 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
OK. Your explanation/rationale makes sense. TY for your reply.
I'll try to improve the documentation.
More information about the Digitalmars-d
mailing list