What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?
Please only one feature per answer.
What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?
Please only one feature per answer.
In C, arrays can be indexed like so:
which is very common.
However, the lesser known form (which really does work!) is:
which means the same as the above.
I struggled a bit about this:
In perl, modules need to return something true.
In Python:
Not a WTF, but a useful feature.
In JavaScript, the following construct
returnsis a syntax error due to the sneaky implicit semicolon insertion on the newline afterundefined
return
. The following works as you would expect though:Even worse, this one works as well (in Chrome, at least):
Here's a variant of the same issue that does not yield a syntax error, just silently fails:
Algol pass by name (illustrated using C syntax):
My biggest most hated feature is any configuration file syntax which includes conditional logic. This sort of thing is rife in the Java world (Ant, Maven, etc. You know who you are!).
You just end up programming in a c**p language, with limited debugging and limited editor support.
If you need logic in your configuration the "Pythonic" approach of coding the configuration in a real language is much much better.