Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Cursor Question
Kenneth C Stahl wrote....
>As I have pointed out repeatedly, GOTO is not necessarily bad. If it easily
and
>clearly solves a problem that would otherwise require complex and obtuse
code,
>then it is appropriate to use GOTO.
And that is the problem with many of these so-called programmers - they can not solve a problem and the resort to using the GOTO statement. Ever tried to maintain spaghetti logic? Which is why I have a very stong distaste for a GOTO statement. And I can not recall ever having to resort to using GOTO statements myself.
>Fortunately Stroustrup understood this problem when he developed C++ - you
>realize, of course, that a throw-catch sequence is the same as a GOTO - it
just
>doesn't use the GOTO word, that's all. In fact, exceptions in C++ can be
used
>in ways that far exceed that which GOTO can since GOTO in C is limited to
the
>scope of a single function.
True. Ditto for Delphi too. But then this is specifically aimed at handling exceptions and not a logic crutch for wanna-be programmers.
>Also, in PL/SQL the EXIT statement is merely a synonym for GOTO.
Not really true - a GOTO is used to branch/jump to another section of logic. An EXIT indicates that the current code block (procedure/method) is unconditionally terminated. Sure, an EXIT can be described as a GOTO statement that jumps to the terminator of the current code block, but by the same token you can see an EXIT statement as just that. Exit the current code block here and now - RETF instead of a JMP if you get my meaning... :-)
The problem with the GOTO statement is not what it does - of course you need to be able to branch the execution of code. You are right - in the "right situation" the use of the GOTO statement may be justified. I think that this concept of "bad GOTO, bad!" is simply a method to get would be programmers to realise that to solve a complex programming problems requires the use of gray matter and not GOTO statements. And whenever one of us "old programmers" see a GOTO statement, we do cringe, as our first reaction is that the programmer got himself/herself into a logic mess and now needs to use a GOTO statement to het out of trouble.
You think banning GOTO is bad? Well, you should see the kernel programming guidelines of Linus. I especially love his comment that you need to use tab idents of 8 characters and if you find yourself on the other side of the screen in a nested IF.. well, you're logic is screwed anyway if you need to use more than 1 nested IF. :-)
regards,
Billy
Received on Tue Jun 22 1999 - 00:47:11 CDT
![]() |
![]() |