News for hackers. Stuff that matters.
Re:Remove the ++ and –- operators by JoeAltmaier on Thursday December 03, 2015 @04:57PM (#10672991)
Huh. C++? You can overload operators, but define your own? I must have missed something.
Re:Remove the ++ and –- operators by janvidar on Thursday December 03, 2015 @05:03PM (#10673032)
Well, I suppose you can #define your own?
Re:Remove the ++ and –- operators by winter_blue on Thursday December 03, 2015 @06:17PM (#10673466)
#define function(arg1, arg2, arg3) exists for creating macro functions, but nothing exists for naturally creating macro unary or binary operators in C and its descendants.
Re:Remove the ++ and –- operators by jsprogrammer on Thursday December 03, 2015 @05:25PM (#10673185)
Each language will have a different meaning of what exactly it means to "define your own". C++ restricts which symbols may be operators, but, you can "define your own +".
Re:Remove the ++ and –- operators by kibwen on Thursday December 03, 2015 @05:42PM (#10673282)
In practice it's very useful to distinguish between a language which "just" has operator overloading vs a language that allows custom user-defined symbolic operators. The existence of the latter is actually one of the few complaints that I have about Swift so far, but I'm sure many people will ardently disagree with me here. :P
Re:Remove the ++ and –- operators by Retra on Thursday December 03, 2015 @07:57PM (#10673923)
It's a wonderful feature for writing DSLs, but it's also confusing when you intermingle DSLs with the standard language. It really tends to balloon the amount of information you need to know to read others' code.