View Single Post
Old 17-09-2011, 07:10 PM   #10
Japo
Autonomous human
 
Japo's Avatar


 
Join Date: Mar 2006
Location: ,
Posts: 4,613
Default

Mind you Horseman, I only thought of the polymorphism alternative because the answer to your application told me to. :P

Quote:
Originally Posted by jonh_sabugs View Post
Just a side note: it's always possible to replace a GOTO with more elegant code, so, you should always avoid it.
We should probably split the goto discussion.

One of my points is that nobody who learned to program after the 1970s is likely to use too many gotos, or any at all. To be honest, I never use goto in practice. And I really don't know a lot, but here's what I googled in a moment. I haven't read it whole, but there may be a consensus that goto is never necessary or desirable if a language provides full flow control, including for example true exception handling and breaking from loops and nested loops; when a language does not provide any given flow control device, gotos might actually be the best and most elegant and legible substitute.

http://en.wikipedia.org/wiki/Goto

http://david.tribble.com/text/goto.html

Quote:
Examples T-2 and N-1 demonstrate that Dijkstra's maxim can be achieved provided that the programming language provides a reasonable set of control structures that can serve in place of simple goto statements.

Examples E-1 and N-2 demonstrate the corollary to this, that if a programming language does not provide reasonably powerful flow control structures, there are programming problems that can be solved reasonably well only by resorting to the use of goto statements.

[...]

Dijkstra's belief that unstructured goto statements are detrimental to good programming is still true. A properly designed language should provide flow control constructs that are powerful enough to deal with almost any programming problem. By the same token, programmers who must use languages that do not provide sufficiently flexible flow control statements should exercise restraint when using unstructured alternatives. This is the Tao of goto: knowing when to use it for good and when not to use it for evil.
From Mr. Linux's mouth (concerning C):
http://kerneltrap.org/node/553

From Steve McConnell, the author of Code Complete:
http://www.stevemcconnell.com/ccgoto.htm

http://www.u.arizona.edu/~rubinson/c...d_Harmful.html

http://dx.doi.org/10.1145/356635.356640
__________________
Life starts every day anew. Prospects not so good...

Last edited by Japo; 17-09-2011 at 07:34 PM.
Japo is offline                         Send a private message to Japo
Reply With Quote