Syntax Intuitiveness aka IQ Test
However, to put an end to my arrogance, the gods pushed me in a direction to see something such non-intuitive and mysterious that made me search the web to just roughly understand what it does.
I was reading a piece of C++ (the almighty!) code and stumbled upon a line like below:
I tried to make sense out of line 3; I tried hard but got nowhere. "What on earth is that? Looks like a method definition but it's not....um...um...um...what the...!?"
A search for
aName in the source tree made things a bit less obscure:
It seemed some kind of pointer magic was going on but I still couldn't understand the mysterious line 3! By the gods...it looked like a method definition that returns
aName type but it was not!
Finally, disappointed by my intuition and creativity, I searched the net to seek the wisdom. The answer was far far away from my expectation. Line 3 is a variable declaration, for gods' sake!. It defines the variable
otherName of type
aName and initialises it with whatever goes between the parenthesis! Yes! My wildest hunches were not even close.
It's in the C++ 11 standard and is called Smart Pointer; Guess why!? You have to be smart to understand the syntax! Kudos to the C++ ISO committee.
I thought standards and language revisions are there to make the language more intuitive and simpler; I was wrong.
Image source: themarkcryan.com