Request for "indexOf" undeprecation.

monarch_dodra monarchdodra at gmail.com
Fri Nov 16 09:40:12 PST 2012


On Friday, 16 November 2012 at 17:30:57 UTC, Denis Shelomovskij 
wrote:
> 16.11.2012 17:18, monarch_dodra пишет:
>> 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).
>
> Thanks, I forget to officially fill this bug some time ago. 
> Pleased you are also finding Phobos bugs.
>
> And I want to mention that `countUntil` is intentionally 
> spoiled. See the sources:
> ---
> // Narrow strings are handled a bit differently
> ---
> and Andrei will probably argue that current dangerous like hell 
> behaviour is correct and such cool feature must be undocumented 
> and developers will be pleased to discover it because of data 
> corruption. :)
>
> But lets not blame Andrei because it was one of his insane big 
> commits:
> https://github.com/D-Programming-Language/phobos/commit/3ea2debb8c4a6a707447c684e94f651924efaa96
> and he probably was superheated and didn't understand what is 
> going on.

Yes, but that was when he wrote "indexOf", in which the index is 
right.

IndexOf was latter simply renamed countUntil, but that changes 
the semantics, and makes the implementation incorrect...


More information about the Digitalmars-d mailing list