Uniform call syntax for operator overloads

Daniel Keep daniel.keep.lists at gmail.com
Tue Jul 27 06:33:53 PDT 2010



Tomek Sowiński wrote:
> bearophile wrote:
> 
>> Tomek S.:
>>
>>> This doesn't work:
>>> int opIndex(int[][] m, uint i, uint j) { return m[i][j]; }
>> That's cute, but in D overloaded operator can be defined inside
>> structs/classes/unions only (this is different from C++).
> 
> Yeah, I know, but why? What bad would happen if operators could be written 
> down with functions-as-members syntax?
> 
> 
> Tomek

Universal Call Syntax is actually just a really old bug in method lookup
for arrays that was never fixed on account of being useful.

That it doesn't work for operators is hardly surprising.


More information about the Digitalmars-d mailing list