Goto In Fenix?


mmm, I don't know, I was taught that using GOTO is the worst way of programming, but honestly am not sure why...
 
Criticism of goto usage:
The GOTO statement has been the target of much criticism, the claim being that use of GOTO produces unreadable and generally unmaintainable "spaghetti code" (whether the alternatives would be just as unreadable and generally unmaintainable is not usually discussed) . As structured programming became more popular in the 1960s and 1970s, many computer scientists came to the conclusion that programs should always use so-called 'structured' flow-control commands such as loops and if-then-else statements in place of GOTO. However, others believed that use of GOTO did not unconditionally lead to poor quality code and that there are some tasks that cannot be straightforwardly accomplished in many programming languages without the use of one or more GOTO statements, such as breaking out of nested loops and exception handling.

Probably the most famous criticism of GOTO is a 1968 letter by Edsger Dijkstra called Go To Statement Considered Harmful [1]. In that letter Dijkstra argued that unrestricted GOTO statements should be abolished from higher-level languages because they complicated the task of analyzing and verifying the correctness of programs (particularly those involving loops). An alternative viewpoint is presented in Donald Knuth's Structured Programming with go to Statements [2] which analyzes many common programming tasks and finds that in some of them GOTO is the most optimal language construct to use.

The Ada language design took note of the above criticisms, but the statement was included in the language despite the criticisms, mainly to support automatically generated code where the goto might prove indispensable. However, the labels used as the destination of a goto statement take the unusual form of an identifier enclosed in double angle brackets (e.g. <<Start_Again>>) and this syntax is not used anywhere else in the language. This makes it easy to check a program for the existence of goto destinations. The goto statement itself takes the simple form goto Start_Again;
Source Wikipedia
 
I'm no expert programmer, but I think GOTO shouldn't be as critisized as it is... After all, it is sometimes usefull (I remember good' old days on my TI82 calculator) and has his direct equivalent in ASM (jmp and its derivates je jle etc) so why ban a goto when it is well placed and simpler than loops or other higher-level instructions?

(Note that I never used Goto again after stopping TI82 developpment, long time ago :) )
 
I think, GOTO is good only for the following scenario:
1) For beginner programmers: I do not think I would have understood the for and while loop without GOTO, I started programming using Basic and GOTO helped me alot.
2) For automated solution that is used to recompile executables from one environment to the other.
3) In some rare cases for optimization purposes, especially in low level languages.
I have so many friends who earn their living through software development, and most of them have not ever used GOTO in their works at all.
 
There is no goto in Fenix.
And I just noticed that this is a pretty late answer... I havent checked throught the Fenix forum here for a long time... dunno why.
 
Back
Top