On Wednesday, 26 October 2016 at 09:54:31 UTC, Dicebot wrote:
On 10/26/2016 12:53 AM, Walter Bright wrote:
It's a small bit, but the idea here is to eliminate if
conditionals where possible:
https://medium.com/@bartobri/applying-the-linus-tarvolds-good-taste-coding-requirement-99749f37684a#.nhth1eo4e
I find it both funny and saddening how many reddit commentators
complained about Linus version of that code is over-complicated.
"Prefer clear code over smart code" principle is good in
general but sometimes it is over-applied to the point where
incompetence gets glorified. And this sucks.
I'm unsure about Linus' version. For this example, I agree that
it is elegant. It is fine in this specific case, because
everything is local within a single function. In general, the
trick to use a pointer to the element probably not a good idea.
The article/Linus does not explain the tradeoffs properly, which
makes it dangerous advice.