Has this ever happened to you? (AKA proof that I am insane)

Started by
19 comments, last by Flarelocke 17 years, 6 months ago
Quote:Original post by Witchcraven
I have seen that type of thing before, and would swear the laws of logic were breaking down. But I always solved the problem, and it is usually a wierd memory thing. The other thing that has messed me up for a while was doing if(a=1)... instead of if(a==1). Sometimes the double = is just not obvious enough.


One way to avoid (a=1) instead of (a==1) is to put the literal value first, ie (1 ==a). That way the compiler will catch (1=a) for you should you omit the second =.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Advertisement
I have found that if you use Visual Studio 2003 or earlier, there actually are gnomes that purposely fuck up your code.

Many times I have had completely bizarre errors pop up because it didn't properly recalculate dependencies, so I'll spend 30 minutes searching for a bug that goes away when I do a Rebuild All.

I haven't yet had this problem with VC2k5, so heres hoping it's fixed for good!

Check out my new game Smash and Dash at:

http://www.smashanddashgame.com/

Quote:Original post by LessBread
Quote:Original post by Witchcraven
I have seen that type of thing before, and would swear the laws of logic were breaking down. But I always solved the problem, and it is usually a wierd memory thing. The other thing that has messed me up for a while was doing if(a=1)... instead of if(a==1). Sometimes the double = is just not obvious enough.


One way to avoid (a=1) instead of (a==1) is to put the literal value first, ie (1 ==a). That way the compiler will catch (1=a) for you should you omit the second =.


That's a good trick actually, I learned about it sometime ago, but for whatever reason I have yet to make habit out of it.


It happens all the time with me and the people I know that if code doesn't work, and you're sure it should, often just the the "magic re-write exactly the same way and then it will work". Happens surprisingly often.
When writing libraries along with the executable I used to forget to re-link the library after modifications therefor things continued behaving the same, even if I erased all source code.
[size="2"]I like the Walrus best.
Quote:Original post by LessBread
Quote:Original post by Witchcraven
I have seen that type of thing before, and would swear the laws of logic were breaking down. But I always solved the problem, and it is usually a wierd memory thing. The other thing that has messed me up for a while was doing if(a=1)... instead of if(a==1). Sometimes the double = is just not obvious enough.


One way to avoid (a=1) instead of (a==1) is to put the literal value first, ie (1 ==a). That way the compiler will catch (1=a) for you should you omit the second =.


Nice trick...I can't believ I never thought of it!

@Tallun
I leave a quiet offering of old soda cans and pizza crust.
For what it's worth, one of the most embarrassing thing I did in my code was to define my dot product function as returning an int...

Quote:Original post by LessBread
One way to avoid (a=1) instead of (a==1) is to put the literal value first, ie (1 ==a). That way the compiler will catch (1=a) for you should you omit the second =.


I had set my text editor (nano) to highlight = and == in different colors.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by load_bitmap_file
I've had this sort of thing happen multiple times. Finally working code one day, screwed up the next. No idea why or how. There are strange gnomes living in my PC.


Trust me, it aren't gnomes...


Make sure to keep cats away from your computer at all times!

Quote:Original post by Toolmaker
Quote:Original post by load_bitmap_file
I've had this sort of thing happen multiple times. Finally working code one day, screwed up the next. No idea why or how. There are strange gnomes living in my PC.


Trust me, it aren't gnomes...


Make sure to keep cats away from your computer at all times!


I would come up with my open image of a garden gnome invading a pc, but I don't have any spare cases. =) You win.
The Eldritch Gnome Collective roams among you. We shall overcome. Donate your cycles or be swept aside by the Gnomish tide.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Quote:Original post by LessBread
Quote:Original post by Witchcraven
I have seen that type of thing before, and would swear the laws of logic were breaking down. But I always solved the problem, and it is usually a wierd memory thing. The other thing that has messed me up for a while was doing if(a=1)... instead of if(a==1). Sometimes the double = is just not obvious enough.


One way to avoid (a=1) instead of (a==1) is to put the literal value first, ie (1 ==a). That way the compiler will catch (1=a) for you should you omit the second =.


wow. so you DO actually program! seriously, this is the first time i hear you saying something technical.

more ontopic: have a good debugger, and just check every variable one by one. that way youre bound to run into it. ive worked in situations where i hadnt, and ive also come to the conclusion often that some logic circuits in my CPU must have shortcircuited, but in the end it always turned out to be me again.

This topic is closed to new replies.

Advertisement