Why Strings as Classes?
Dee Girl
deegirl at noreply.com
Wed Aug 27 16:45:29 PDT 2008
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.
> D's standard arrays are a bad example of this: since they're built in,
> everyone uses them, so it's difficult to replace them with a linked list
> or something else. The effect is more pronounced with associative
> arrays, since there isn't as much choice in lists as in dictionaries.
> But they're so damn useful, and the syntax is hard to match.
I hope Walter adds new data structure that work with std.algorithm. I am not sure. But I think std.algorithm is make so it works with other types. Not only arrays.
More information about the Digitalmars-d
mailing list