Friday, October 17, 2008



Yeah, I had to put a goto into the code today. I suck.

I promise I'll take it out when I have time to do some refactoring. But you see, when some moron writes an 872-line function with eleven levels of if and while statements, it's difficult to find ways to clean things up.

Oh fer god's sake. There's nothing wrong with judicious use of gotos, Dijkstra notwithstanding. Nothing to fix here, move along. :)

I like Knuth's supposed quip "Structured Programming Using Goto Statements" (rumouredly sub-titled "'Goto Statement Considered Harmful' Considered Harmful")
Unfortunately, this one can't be considered "judicious". It just made bad code worse.
A lot of people miss the point that Dijkstra's original letter was pointing out that it was the "unbridled" use of goto that was considered harmful (in an era when most programmers only method of control flow was the goto). As typical, the structured control flow guys latched onto the letter and turned it into a religion (I guess Dijkstra knows how George Lucas feels :-).

So now we have a situation where people use a statement almost like a dirty word, and publish their confessions on their blog for repentence ...

I used 3 gotos recently in the same function (first time for something like 5+ years, although I hadn't done much C recently), although admittedly it was "very scratch demo code" (would've been refactored if it weren't being thrown away). The first comment said something along the lines of "burning in hell" for the use of goto, and by the third it was "getting crispy now" (and they were all exiting to a common cleanup point).

See, now you've got me confessing. :-/

Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?