Problem overloading operator for a struct with an immutable member

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 25 23:40:24 PDT 2015


On Thu, 26 Mar 2015 05:44:13 +0000, Jean pierre wrote:

>   auto i = s++; // OUCH, but we expect S.i...

but why one expecting `i` here? there IS `opUnary` overload, and `++` 
corretly transformed to prefix form. there is simply NO postfix form in 
semantically analyzed code, *all* postfix increments and decrements are 
transformed.

or, to say it another way, D has no postfix inc/dec operator, there are 
only prefix forms. postfix form it just a compiler syntactic sugar.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150326/e2cf984b/attachment.sig>


More information about the Digitalmars-d-learn mailing list