This code is evil
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
Anotherthing is inconsistently cased, pure evil indeed!
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
-
Anotherthing is inconsistently cased, pure evil indeed!
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
That is indeed the real crime here.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
So.... We should both be very grateful that you don't do peer review for me. I would have tucked in an anonymous function just to piss you off.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
den2k88 wrote:
but only if the condition of the ternary operator is true.
There's certain elegance to that which I can't help but admire.
Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
At least it's all on one line. :)
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
There's a lack of prefix and postfix operators, don't you see that? The code should be corrected to:
something = Anotherthing - ((++condition == 0) ? (assignment_here = object->method()) : --someothervalue);
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
-
There's a lack of prefix and postfix operators, don't you see that? The code should be corrected to:
something = Anotherthing - ((++condition == 0) ? (assignment_here = object->method()) : --someothervalue);
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
There are in other bits of code. This is as of now the single line of code with the most horrors I ever seen.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
-
There are in other bits of code. This is as of now the single line of code with the most horrors I ever seen.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
Add a lambda to it!
-
I would only make a couple of changes
something = Anotherthing - (condition ? someothervalue : (assignment_here = object->method()));
I never liked
condition == 0
I like
!condition
much better.
Currently I am so fortunate that my programming is in a language where (numeric != bool) :-) In my last plain C project, I happened to set up a "#define ever ;;" so that I could write "for (ever) {..." to make an infinite loop, which is not uncommon in embedded code. (In the CHILL language, made for programming phone switches, "DO FOR EVER ..." is defined in the basic language.) One of the other team members reacted quite fiercly to this, searching through the entire code base for "for (ever)", adding a nasty commit message about "someone" who were trying to make funny jokes in the code, and he changed it to the proper "while (1)". The header project files did define "true" and "false" constants, but he woudn't accept even "while (true)": There is one proper way to make an infinte loop in C, and that is "while (1)". I was seriously considering to change it to "while (2)", with a commit message that 2 makes it twice as clear that the loop should run for (ever), but I decided not to. My relationship to that guy was bad enough without further provocations. So, provided "condition" is a bool variable, or an numeric variable that stores nothing but the value of bool expressions, I certainly agree that "!condition" is the proper way. But if "condition" is a numeric value treated as such (e.g. a counter from n down to 0), treating it as a bool for flow control is bad. Then "condition == 0" is far better. Same with pointers. I detest "if (!nextpointer) { /*leave loop*/" - that should be "if (nextpointer == null)" (or "nil" or "empty" or whatever your favorite language calls is). Which makes me think of that really nice construction I have encountered in a single language: "FOR currentpointer IN listhead:nextpointer DO..." - "nexpointer" being the name of a pointer member in the class "listhead" (and "currentpointer") points to.
-
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true. This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X