A opIndexUnary quiz

Ali Çehreli acehreli at yahoo.com
Tue Jan 1 10:08:01 PST 2013


On 01/01/2013 09:52 AM, bearophile wrote:
 > void opIndexUnaryRight(string op)(uint i) if (op == "++") {
 > data[i]++;
 > }

I admit that I could not see the error as I was reading the code. I 
thought that I was learning something new from that code. ;)

 > Do you think this code should produce some compilation errors?

That is hard to answer. It makes me think that perhaps the special 
function names should all start with double underscores. Only then the 
compiler would have the right to produce a compilation error for the 
code above. :-/

Ali



More information about the Digitalmars-d-learn mailing list