Manfred_Nowak <[email protected]> wrote:
What is the rationale for having both: normal and square brackets?
Mostly that C has both. Changing this would make the language feel rather more different from C/C++ than it already does. It is also syntactic sugar for element lookup. Rather than having to write some function name (that may or may not be the same for all collections), you can use [].
I ask because in plain old C I interpreted the lexical difference of funtion calls and accesses to elements of arrays as a permanent hint for linear runtime in case of arrays. But because of `opIndex' this assumption has been invalidated a long time ago.
No it hasn't. opIndex should still be O(1), it just can't be enforced. -- Simen
