Article 6Y7B9 CodeSOD: Classic WTF: When it's OK to GOTO

CodeSOD: Classic WTF: When it's OK to GOTO

by
Alex Papadimoulis
from The Daily WTF on (#6Y7B9)
Where did you GOTO on your vacation? Nowhere. GOTO is considered harmful. Original --Remy

Everybody knows that you should never use "goto" statements. Well, except in one or two rare circumstances that you won't come across anyway. But even when you do come across those situations, they're usually "mirage cases" where there's no need to "goto" anyway. Kinda like today's example, written by Jonathan Rockway's colleague. Of course, the irony here is that the author likely tried to use "continue" as his label, but was forced to abbreviate it to "cont" in order to skirt compiler "reserved words" errors.

while( sysmgr->getProcessCount() != 0 ){ // Yes, I realize "goto" statements are considered harmful, // but this is a case where it is OK to use them cont: //inactivation is not guaranteed and may take up to 3 calls sysmgr->CurrentProcess()->TryInactivate(); if( sysmgr->CurrentProcess()->IsActive() ) { Sleep(DEFAULT_TIMEOUT); goto cont; } /* ED: Snip */ //disconnect child processes if( sysmgr->CurrentProcess()->HasChildProcesses() ) { /* ED: Snip */ } /* ED: Snip */ if( sysmgr->CurrentProcess()->IsReusable() ) { sysmgr->ReuseCurrentProcess(); goto cont; } sysmgr->CloseCurrentProcess();}

proget-icon.png [Advertisement] ProGet's got you covered with security and access controls on your NuGet feeds. Learn more.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments