Click here to Skip to main content
15,885,914 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Jeremy Falcon25-Jun-15 5:42
professionalJeremy Falcon25-Jun-15 5:42 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Freak3025-Jun-15 21:32
Freak3025-Jun-15 21:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Jeremy Falcon26-Jun-15 3:23
professionalJeremy Falcon26-Jun-15 3:23 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Bruce Patin26-Jun-15 6:16
Bruce Patin26-Jun-15 6:16 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
jibalt26-Jun-15 9:53
jibalt26-Jun-15 9:53 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
TheGreatAndPowerfulOz30-Jun-15 9:15
TheGreatAndPowerfulOz30-Jun-15 9:15 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
DSewhuk30-Jun-15 11:02
DSewhuk30-Jun-15 11:02 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Daniel Pfeffer30-Jun-15 18:08
professionalDaniel Pfeffer30-Jun-15 18:08 
DSewhuk wrote:
If they had a default: case then I could almost see a reason. Consider the case if the bool was neither true or false. For most x86 C's there are 254 other trues and 65534 other trues on the DSP I code. I remember some very picky standards about what to do with unexpected values for space computing. Pesky alpha/beta/gamma particles flipping RAM cells around and the like.

Interesting; most programmers never have to consider the possibility of failure of the CPU/memory in their code. Does this imply that you must use a form of trinary logic (true / false / bad value) in such code?

DSewhuk wrote:
I have fixed my share of mixed boolean true logics gone bad. Is it a one, -1 or non-zero?

My problem is - how many compilers assume that a Boolean has only 'true' or 'false' values, ignoring the 'default' clause in this case? One solution would be to have your interface code treat 'Boolean' values as appropriate-size integers, converting to an appropriate type (e.g. true / false / bad value). This leads us to the logic above, where Boolean values are not truly Boolean. Smile | :)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
ZurdoDev25-Jun-15 6:00
professionalZurdoDev25-Jun-15 6:00 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Silvabolt25-Jun-15 6:57
Silvabolt25-Jun-15 6:57 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Rob Grainger25-Jun-15 9:04
Rob Grainger25-Jun-15 9:04 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
DJ van Wyk25-Jun-15 19:55
professionalDJ van Wyk25-Jun-15 19:55 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Kirk 1038982126-Jun-15 3:22
Kirk 1038982126-Jun-15 3:22 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Bruce Patin26-Jun-15 6:26
Bruce Patin26-Jun-15 6:26 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
cramotowski27-Jun-15 8:40
cramotowski27-Jun-15 8:40 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
phil.o25-Jun-15 10:23
professionalphil.o25-Jun-15 10:23 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
kmoorevs25-Jun-15 10:59
kmoorevs25-Jun-15 10:59 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Sander Rossel25-Jun-15 20:32
professionalSander Rossel25-Jun-15 20:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK25-Jun-15 22:09
Simon O'Riordan from UK25-Jun-15 22:09 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
ScottM125-Jun-15 22:32
ScottM125-Jun-15 22:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Eddy Vluggen25-Jun-15 23:28
professionalEddy Vluggen25-Jun-15 23:28 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK25-Jun-15 23:47
Simon O'Riordan from UK25-Jun-15 23:47 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Eddy Vluggen26-Jun-15 0:09
professionalEddy Vluggen26-Jun-15 0:09 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK26-Jun-15 0:49
Simon O'Riordan from UK26-Jun-15 0:49 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Scott Corbett26-Jun-15 2:23
Scott Corbett26-Jun-15 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.