std.string and std.algorithm: what to do?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu May 14 06:55:08 PDT 2009


I'm not sure what needs to be done about the combo string + algorithm. 
There's quite some overlap, and also functions that have the same name 
in both modules (e.g. find()), which forces you to disambiguate.

Should std.algorithm automatically recognize strings and proceed 
accordingly, should it just consider them straight arrays and leave 
everything else to std.string (risky!), or refuse to handle strings?

Also, I dislike the signature int find() that returns -1 if not found. 
Time and again experience shows that find() returning a range is much 
better in real code because it works seamlessly when the 
substring/element was not found (no more need for an extra test!)

So I want to rename std.string.find() into something like findIndex or 
indexOf. But then we also have ifind, rfind, irfind. Ideas for renaming?


Andrei



More information about the Digitalmars-d mailing list