Re: Semantics of postfix ops for classes

2012-07-25 Thread Don Clugston
On 20/07/12 17:12, Andrej Mitrovic wrote: According to TDPL postfix operators are rewritten to call prefix operators, e.g. on this call for some user-type object named a: auto b = a++; // is converted to: auto b = ((ref x) { auto t = x; ++x; return t; })(a); But I don't see how this is

Re: Semantics of postfix ops for classes

2012-07-25 Thread Christophe Travert
Don Clugston , dans le message (digitalmars.D:173192), a écrit : The question really is, do postfix ++ and -- make sense for reference types? Arguably not. From a theoretical sense, the existing behaviour does make sense, but in practice, every time it is used, it is probably a bug. The

Semantics of postfix ops for classes

2012-07-20 Thread Andrej Mitrovic
According to TDPL postfix operators are rewritten to call prefix operators, e.g. on this call for some user-type object named a: auto b = a++; // is converted to: auto b = ((ref x) { auto t = x; ++x; return t; })(a); But I don't see how this is reasonable for classes. Examine: struct Struct {

Re: Semantics of postfix ops for classes

2012-07-20 Thread Andrej Mitrovic
On 7/20/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: According to TDPL Oh and that's page 369 for those wondering.