8 ms·
The long arrow operator in C++
- pzone 9y agoCute. Though if I actually saw this in a codebase I might tear my hair out.
- mlvljr 9y agoLong hair?
- ented 9y agoWhy??????????????????????????
- std_throwaway 9y agoIt's a joke.
- hinkley 9y agoThose who do not fear Poe's Law are doomed to repeat it.
- ggdG 9y agoThey had me because it was so similar to the - very real - combinations of "conses" in the lisp world: caaaar, cdaddr, cddddr and so on. https://franz.com/support/documentation/6.0/ansicl/dictentr/carcdrca.htm https://franz.com/support/documentation/6.0/ansicl/dictentr/...
- TeMPOraL 9y ago"Science isn't about why - it's about why not. Why is so much of our science dangerous? Why not marry safe science if you love it so much?"
- amelius 9y agoDid you overload the "?" operator?
- marcosdumay 9y agoI think the parser will fail anyway. You can't overload syntax.
- Sharlin 9y agoI think you mean "Why??!??!??!??!??!??!??!??!??!" [1] [1] https://stackoverflow.com/questions/7825055/what-does-the-c-operator-do https://stackoverflow.com/questions/7825055/what-does-the-c-...
- lower 9y agoI remember this from a similar example in C: #include <stdio.h> int main() { int x = 10; while (x --> 0) /* x goes to 0 */ { printf("%d ", x); } } (prints 9 8 7 6 5 4 3 2 1 0) https://stackoverflow.com/questions/1642028/what-is-the-operator-in-c https://stackoverflow.com/questions/1642028/what-is-the-oper...
- fiddlerwoaroof 9y agoYour description of the result is a valid Lisp expression. . .As long as one has defined a prints function.
- jfktrey 9y agoWorks just as well in Java. I'll have to slip this in to my next code review :)
- beeforpork 9y agoCareful with these jokes -- your coding style nazis will give you a new coding rule in return to prevent this madness in the future!
- mcguire 9y agoOr, worse, adopt it as the way to do things. I blame Haskell, Scala, and Ruby.
- lower 9y ago> Or, worse, adopt it as the way to do things. Thompson, Ritchie and Kernighan admit that Unix was a prank http://www.stokely.com/lighter.side/unix.prank.html http://www.stokely.com/lighter.side/unix.prank.html
- deleted 9y ago[deleted]
- repsilat 9y ago
- std_throwaway 9y agoIn python there is the term "pythonic" describing if something is in the spirit of the languages founding fathers. As in: "The most pythonic way to write this down is ..." or "Map/filter don't feel very pythonic." What is the equivalent term or expression for being in the spirit of C++? The article, while a joke (just like C++ originally, look it up), feels very C++y.
- xsmasher 9y ago"Such-and-such is (not) idiomatic C++"
- 0xbear 9y agoI don't think there's broadly "idiomatic" C++. There's "idiomatic Google C++" though.
- saghm 9y agoWhile what's idiomatic is subjective, I think there's plenty that everyone can agree is not idiomatic, so I think GP's quote is still pretty commonly used
- sqeaky 9y agoI think we can all agree that actively re-purposing the postfix-- operator to perform a dereference on a smart is definitely not idiomatic. Idiomatic might be fuzzy, but it definitely does not include active attempts obfuscation, malice or jokes. The code in the article could be any of these depending on context.
- saghm 9y agoYep, no arguments here!
- int_19h 9y agoNot in a literal sense of the word, perhaps. But in practice, "idiomatic C++" is taken to mean STL- and Boost-like.
- marklgr 9y agoObligatory "x slides to zero": while (x --\ \ \ \ > 0) printf("%d ", x);
- TeMPOraL 9y agoAlso, never forget, the C++ Multi-Dimensional Analog Literals: assert( ( o-------------o |L \ | L \ | L \ | o-------------o | ! ! ! ! ! o | ! L | ! L | ! L| ! o-------------o ).volume == ( o-------------o | ! ! ! ! ! o-------------o ).area * int(I-------------I) ); http://www.eelis.net/C++/analogliterals.xhtml http://www.eelis.net/C++/analogliterals.xhtml
- Longhanks 9y agoThis is some serious black magic. I cannot wrap my head around the fact that this is valid C++...
- blattimwind 9y agoThese are "just" some free symbols (o, I, L) used with overloaded operators (!, |, --). The rest is pretty formatting with whitespace which isn't relevant to functionality.
- awinter-py 9y agoand don't forget the equally useful and serious integer unary-double-equal greater-than operator 8==>
- digi_owl 9y agoI guess if this was Reddit, we would have had a meme storm by now...
- kuon 9y agoEven if it's a Joke, C++ lost me a decade ago...
- sqeaky 9y agoThat's a shame. C++11/14/17 each make the language better and deal with many of the might have pushed someone away in the past. The typing is getting stronger, the library richer and hard things easier. If you know about or can google RAII and are willing to lookup things on occasion to pick algorithms or just the right member function, code gets very clean. After not too long the looking stops because the std lib is still pretty small compared to other languages. But if you have already moved to Rust I can't make an objective argument for it.
- jussij 9y ago> C++11/14/17 each make the language better and deal That may be true, but all you are seeing is C++ copying from every other language in an effort to once again become relevant. IMHO in this modern day and age there are so many easier, better, more expressive, easier to use languages than C++ to choose from. And that is coming from someone who spent a lot of time coding C++ some 15 years ago.
- pcwalton 9y ago> That may be true, but all you are seeing is C++ copying from every other language in an effort to once again become relevant. To be fair, that's what every other language does too. There are few truly novel ideas in industry programming languages.
- sqeaky 9y ago> an effort to once again become relevant. I was unaware that being the 2nd and 3rd most popular language made it not relevant when I guess nothing is relevant except Java. (Per the Tiobe index) If you need high level abstractions and the ability to tweak for performance at the lowest levels the it is either C++ or Rust, and if you need a mature ecosystem that really only leaves C++. Game devs, Google, Facebook, HPC and tons of stuff and now with emscripten and WASM we get to compete with JS devs for in browser games too!
- Double_a_92 9y agoLaw of Demeter, much?
- jussij 9y agoIs this an Aprils fools joke posted a few months late?
- alejohausner 9y agoYou can even approach 0 from left and right simultaneously: while (a -->> k --> 0 <-- b <<-- c) and you can have dashed arrows too: k = a <- - - - - b;
- cloop_floop 9y agothis is beautiful AND insane bravo
- trelliscoded 9y agoIn the dashed case, k is going to be zero or one (a<b is true or false). This works, though: int a=0, b=4; while(a < - - - - --b) { printf("b: %d\n", b); }
- alejohausner 9y agoI just spent an hour constructing a class called Morse such that this outputs "HELLO WORLD!": Morse m; cout << (++++m) << (+m) << (+-++m) << (+-++m) << (---m) << ", " << (+--m) << (---m) << (+-+m) << (+-++m) << (-++m) << "!\n"; Damn you, C++! Why won't you let me overload the . operator? ;-)