D dropped in favour of C# for PSP emulator

jerro a at a.com
Fri May 11 19:55:32 PDT 2012


> Yes, "in" for statically-sized arrays does make sense because 
> the complexity if bound at compilation time.
>
> Andrei

But complexity is not the only problem with the proposed
operator in for arrays. That operator does not represent the
same operation as operator in for associative arrays. Looking
up an element based on its key is different from looking it up
based on its value. The following  would be true for the
proposed operator in for arrays:

!(a in b) || *(a in b) == a

And the following is true for operator in for associative
arrays:

!(a in b) || *(a in b) == b[a]

The same operator should not be used for fundamentally
different operations. I don't think using operator in to look
up array elements based on their value is any better than
using left shift operator to write to streams or using plus
to concatenate strings. If operator in worked on arrays, it
should actually take an index as the left operand and return a
pointer to the element at that index if the index was less than
array length and null otherwise. But that wouldn't be very
useful.


More information about the Digitalmars-d mailing list