4 ms·
A quite memorable article [1] described a “backwards” message-passing technique in C++ using operator overloading so you could do stuff like: obj<-method a
by cobbzilla 6mo ago
A quite memorable article [1] described a “backwards” message-passing technique in C++ using operator overloading so you could do stuff like:
obj<-method arg1 arg2;
[1] https://jacobfilipp.com/DrDobbs/articles/DDJ/1996/9608/9608e/9608e.htm https://jacobfilipp.com/DrDobbs/articles/DDJ/1996/9608/9608e...
- supliminal 6mo agoWasn’t this an April 1st entry? :-)
- raverbashing 6mo agoI guess something like https://stackoverflow.com/questions/1642028/what-is-the-operator-in-c-c/67828001#67828001 https://stackoverflow.com/questions/1642028/what-is-the-oper...
- zzrrt 6mo agoI skimmed the article and haven't gotten out the compiler or source files, but does anyone understand how arg1 and arg2 with space and no operator in between are syntactically valid C++, and what do they do?
- zzrrt 6mo agoAha, the syntax is actually `button <- setSize << 10 << 20;` according to DEMO.CPP in /1996/9608/dynacpp.zip of the ISO. So operator-() initializes the Message object, operator<<() stores the parameters into it, which is then passed to operator<() to invoke the function. I guess the HTML page was badly transcribed or failed to escape the characters.
- cobbzilla 6mo agoYes! The linked article didn’t capture all the symbols in the original DDJ article. There were in fact `<<` preceding each arg. The actual line was: obj<-method << arg1 << arg2 which requires overloading the less-than, unary negation, and the double-less-than operators.