Post increment and decrement

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 22 03:26:05 PDT 2015


On 3/15/2015 1:45 AM, Jonathan M Davis via Digitalmars-d wrote:
> On Saturday, March 14, 2015 15:35:24 Ali Çehreli via Digitalmars-d wrote:
>> C++ needs a rule like D's, which will never be there.
> Yep. By making it so that you only overload a single operator for both
> versions of increment, we avoid the whole problem in D, similar to how
> having opCmp avoids bugs related to having to define each comparison
> operator individually as is the case in C++.

There's another reason why D specifies some arithmetic identities for 
overloading arithmetic operators. It's to make abominations like C++ iostreams 
that overload operators for non-arithmetic tasks much harder to do.


More information about the Digitalmars-d mailing list