Why Strings as Classes?
superdan
super at dan.org
Wed Aug 27 16:53:27 PDT 2008
Dee Girl Wrote:
> 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.
cool. dee there's two things u said i like. one was the contract view of complexity guarantee. after all o(n) is a weaker guarantee than o(1). and heck nobody complain if someone comes with sort that works in o(n log log n). so there's some sort of complexity hierarchy. never thot of it that way. that's as cool as the other side of the pillow.
2nd thing i liked was the performance vs. complexity contrast. linear search in ruby has less performance than linear search in d. but both have the same complexity. that's universal. spot on girl. good food for thot while i get drunk at tgiw. thanx.
More information about the Digitalmars-d
mailing list