www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: yank unary '+'?

reply bearophile <bearophileHUGS lycos.com> writes:
Thanks to Andrei to explain the situation better.

Denis Koroskin:
 OpTrue also implies opFalse, which is redundant.

C# allows to define both methods, but I don't like that. The compiler can just return the negation of opTrue, no need of opFalse. Is this a good enough solution? It looks better than using !!. Bye, bearophile
Dec 07 2009
parent Don <nospam nospam.com> writes:
bearophile wrote:
 Thanks to Andrei to explain the situation better.
 
 Denis Koroskin:
 OpTrue also implies opFalse, which is redundant.

C# allows to define both methods, but I don't like that. The compiler can just return the negation of opTrue, no need of opFalse. Is this a good enough solution? It looks better than using !!.

Only the compiler uses !! opUnary("!") is opFalse. BTW, the last line of operatoroverloading.html is: "The operators ! && || ?: and a few others will likely never be overloadable." Never say never.
Dec 07 2009