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

Steven Schveighoffer schveiguy at yahoo.com
Fri May 15 05:55:50 PDT 2009


On Thu, 14 May 2009 18:15:01 -0400, Derek Parnell <derek at psych.ward> wrote:

> On Thu, 14 May 2009 17:33:40 -0400, Steven Schveighoffer wrote:
>
>> On Thu, 14 May 2009 17:21:02 -0400, Derek Parnell <derek at psych.ward>  
>> wrote:
>
>> Not really.  What could funcA possibly do with the index without the
>> string itself?  If it's just a flag (uint.max or not), then funcA should
>> be:
>>
>> funcA(bool found, ...)
>>
>> and you call it with
>>
>> funcA(find(needle, haystack) < haystack.length, xyzzy)
>>
>> This doesn't cause any problems with people who use Tango, which returns
>> the length if not found.  In other words, if you find yourself writing
>> code to "morph" the length into uint.max or -1, you are thinking about  
>> the
>> problem incorrectly.
>
> Who said that I had control of how funcA() was implemented?

Then I guess the rebuttal to that is, why should we make the design of  
std.string suffer to support a poorly designed legacy function?

It's easy enough to write a wrapper around the properly designed string  
function to return what you wish.

-Steve



More information about the Digitalmars-d mailing list