The original context of the "GOTO considered harmful" is lost on most of us, as at the time there were large swaths of developers that were trained before structured programming took off, so people were using global variables and GOTOs instead of procedures and functions. GOTO has its place, specially in C. It is sinful to jump into a different function and pass around information as global state. GOTO as functionali…
Growing up in the 80s, that's how a lot of books taught us BASIC, because they catered to a lowest-common-denominator implementation. Fortunately, I was using BBC BASIC, with functions, procedures and REPEAT-UNTIL (and later WHILE and CASE), and the BBC-specific books taught structured programming.
If goto statements are bad why does linux src have more than 10k of them?
21–30 of 48 posts
Re: If goto statements are bad why does linux src have more than 10k of them?
#22https://web.archive.org/web/20120331202351/http://kerneltrap...
Re: If goto statements are bad why does linux src have more than 10k of them?
#23The original context of the "GOTO considered harmful" is lost on most of us, as at the time there were large swaths of developers that were trained before structured programming took off, so people were using global variables and GOTOs instead of procedures and functions. GOTO has its place, specially in C. It is sinful to jump into a different function and pass around information as global state. GOTO as functionali…
>It is sinful to jump into a different function So sinful you can't in C
Re: If goto statements are bad why does linux src have more than 10k of them?
#24The original context of the "GOTO considered harmful" is lost on most of us, as at the time there were large swaths of developers that were trained before structured programming took off, so people were using global variables and GOTOs instead of procedures and functions. GOTO has its place, specially in C. It is sinful to jump into a different function and pass around information as global state. GOTO as functionali…
>It is sinful to jump into a different function So sinful you can't in C
https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Labels-as-Values....
Re: If goto statements are bad why does linux src have more than 10k of them?
#25Re: If goto statements are bad why does linux src have more than 10k of them?
#26Re: If goto statements are bad why does linux src have more than 10k of them?
#27Because it is written in C. "Goto statements are bad" meant: lets start using languages that offer higher level constructs to replace the current usage of goto. Things like "loops" and "functions" and "exceptions". C did not get the memo.
Re: If goto statements are bad why does linux src have more than 10k of them?
#28Contrary to popular reputation, there are a handful of use cases where "goto" makes the code simpler, cleaner, more readable, and (in rarer cases) faster. In these cases, you should use goto statements. A good programmer can recognize these cases and use goto appropriately. Goto is never necessary in a strict sense but occasionally it can eliminate some pretty ugly spaghetti code. The use cases for goto I see are pri…
And C doesn't have exceptions, which otherwise would cover a lot of where goto's are used.
Re: If goto statements are bad why does linux src have more than 10k of them?
#29This form of blind programming is terribly dangerous. It takes focus away from the task and placed on the process.
Engage with the problem, engage with the computer. Do not engage with autocratic decrees and programming equivalencies of heretic and kosher.
Goto does something specific. If you need that specific thing then that's why it's there. Ceremonial rituals be damned
Re: If goto statements are bad why does linux src have more than 10k of them?
#30Contrary to popular reputation, there are a handful of use cases where "goto" makes the code simpler, cleaner, more readable, and (in rarer cases) faster. In these cases, you should use goto statements. A good programmer can recognize these cases and use goto appropriately. Goto is never necessary in a strict sense but occasionally it can eliminate some pretty ugly spaghetti code. The use cases for goto I see are pri…
And C doesn't have exceptions, which otherwise would cover a lot of where goto's are used.