On Tuesday, May 01, 2012 16:31:25 Alex Rønne Petersen wrote: > 1) So because some people might use a feature incorrectly due to lack of > knowledge in algorithms and data structures, we should cripple the language?
If in is not restricted to a particular level Big-O complexity, then you cannot safely use it in generic code. That's why all of the functions in std.container give their Big-O complexity. In C++ [] is supposed to be O(log n) at worst. I would expect it to be the same in D, and since in is doing essentially the same operation, I would expect it to have the same Big-O complexity. No, nothing is stopping a programmer from giving it horrible complexity, but the standard library and language should _definitely_ stick to O(log n) worst case for in and []. It would be a disaster for generic algorithms if in worked on normal arrays, because it would not be possible to maintain the required Big-O complexity. - Jonathan M Davis