Why Strings as Classes?

Nick Sabalausky a at a.a
Wed Aug 27 21:43:00 PDT 2008


"Dee Girl" <deegirl at noreply.com> wrote in message 
news:g94oup$2mk7$1 at digitalmars.com...
> Christopher Wright Wrote:
>
>> Dee Girl wrote:
>> > I am confused to. Why is making [] do find good and making find do [] 
>> > wrong? How do you make decision? To me it looks the opposite way. 
>> > Because find is less demanding contract than []. In design a stronger 
>> > contract can replace a weaker contract. Not the inverse. Thank you, Dee 
>> > Girl
>>
>> Choosing the data structure used is never the job of the code you're
>> giving the data to.
>
> Yes. But code should refuse data if data does not respect an interface.
>
> I think binary_search never should work on list. It does really bad thing 
> when linear search is the correct thing. Do you think it should?
>
>> It's the job of whatever creates the data structure.
>> By giving two functions where the only difference is performance
>> guarantees, you're allowing the called code to determine what data
>> structures it accepts, not based on the operations the structure
>> supports, but based on the performance of those data structures.
>
> I do not think there is anything wrong. And for me performance and 
> complexity is very different words. Performance is like dmd -O -release 
> against dmd -debug. Or asm implementation of function. Complexity is very 
> different thing and essential for algorithm.
>

True. But, since performance (as you described it) is not particularly 
relevant to these discussions, some of us have been (perhaps incorrectly) 
using "performance" and "complexity" interchangably. We mean "complexity".





More information about the Digitalmars-d mailing list