
The long arrow operator in C++ - santaclaus
http://cukic.co/2017/07/12/the-long-arrow-operator-in-cxx/
======
marklgr
Obligatory "x slides to zero":

    
    
      while (x --\
                  \
                   \
                    \
                     > 0)
           printf("%d ", x);

~~~
TeMPOraL
Also, 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
This is some serious black magic. I cannot wrap my head around the fact that
this is valid C++...

~~~
blattimwind
These 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.

------
lower
I 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-
oper...](https://stackoverflow.com/questions/1642028/what-is-the-operator-
in-c)

~~~
jfktrey
Works just as well in Java. I'll have to slip this in to my next code review
:)

~~~
beeforpork
Careful with these jokes -- your coding style nazis will give you a new coding
rule in return to prevent this madness in the future!

~~~
mcguire
Or, worse, adopt it as the way to do things.

I blame Haskell, Scala, and Ruby.

~~~
lower
> 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)

------
alejohausner
You 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;

~~~
trelliscoded
In 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
I 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? ;-)

------
std_throwaway
In 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.

~~~
barsonme
I think the word is "confusing"

~~~
TallGuyShort
I was once taught, "In C, calling a solution 'interesting' is a compliment. In
Python, that's an insult. Maybe we should go with "interesting".

------
pzone
Cute. Though if I actually saw this in a codebase I might tear my hair out.

------
kuon
Even if it's a Joke, C++ lost me a decade ago...

~~~
sqeaky
That'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
> 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.

~~~
sqeaky
> 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!

------
awinter-py
and don't forget the equally useful and serious integer unary-double-equal
greater-than operator

    
    
      8==>

~~~
digi_owl
I guess if this was Reddit, we would have had a meme storm by now...

------
Double_a_92
Law of Demeter, much?

------
jussij
Is this an Aprils fools joke posted a few months late?

------
ented
Why??????????????????????????

~~~
std_throwaway
It's a joke.

~~~
ggdG
They 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/...](https://franz.com/support/documentation/6.0/ansicl/dictentr/carcdrca.htm)

