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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu May 14 09:39:28 PDT 2009


Steve Teale wrote:
> Andrei Alexandrescu Wrote:
> 
>> dsimcha wrote:
>>> == Quote from Andrei Alexandrescu
>>> (SeeWebsiteForEmail at erdani.org)'s article
>>>> 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?
>>> I like the idea of automatically specializing on strings, at
>>> least on the surface. It's less to remember for the programmer,
>>> less annoying naming collisions, and stuff "just works".  You get
>>> your generic std.algorithm stuff when you need it and your more
>>> optimized/variable length character encoding stuff when you need
>>> it without having to explicitly specify which one you want.
>> Cool! So then how do I rename find, ifind, rfind, and irfind in
>> std.string?
>> 
>> Andrei
> 
> Maybe you should rename the new stuff - indexOf, etc. Why break
> existing code that works with D1 and D2 and tests for -1. I think
> that find may be a rather widely used function.

That's the gist of the problem. The new functions don't return indexOf, 
the old ones do. I'd rather define good names and break things now, than 
stay with bad names forever.

Andrei



More information about the Digitalmars-d mailing list