It seems Fortran is not FORTRAN.C and C++ have goto. Pascal and Object Pascal do as well. It's sometimes useful (Oh, no! Sacrilege!).
It seems Fortran is not FORTRAN.C and C++ have goto. Pascal and Object Pascal do as well. It's sometimes useful (Oh, no! Sacrilege!).
Yes, I always knew Fortran as FORTRAN.(And Basic as BASIC).
FORTRAN without GOTO is Fortran.(A bit of trivia. Before Fortran 90, the language is officially spelled FORTRAN, for Fortran 90 and later, it is spelled Fortran.)
It is interesting to see the same tired GOTO discussion being promulgated 70 years after Edsger Dijkstra wrote "GOTOs, considered harmful". The mass phobia of GOTO has always been unfounded. A GOTO is a valid way of exiting any logical block of code, but should never be used to enter a logical block. Unconditional jumps are in the machine code for valid reason.
Some people like to exchange opinions. I don't share such a hobby, but I understand it.tired GOTO discussion
Nothing else exists. A loop construct of some language is also made of jumps.I like GOTO and I'll defend your right to use it. GOTO is the mother of all instructions. GOTO is the foundation of modern computing.
They are "abstracting". Hiding details that are not particularly relevant at their level. Just as a procedure call is an abstraction. You can always doEssentially the higher level languages are "hiding"
move *sp, arg1
sub sp, 4
move *sp, label1
sub sp, 4
jmp func1
label1:
add sp,8
func1(arg1).Around 1971, I worked with a guy who was rewriting a system that monitored dynamometer test stands for truck engines in FORTRAN. (It ran on an IBM 1800 system.) He had adopted structured programming, and he charted his programs using Nassi–Shneiderman structured flowcharts, then implemented them in FORTRAN using GOTOs only where necessary to implement the structured programming constructs. His GOTOs were not harmful.It is interesting to see the same tired GOTO discussion being promulgated 70 years after Edsger Dijkstra wrote "GOTOs, considered harmful". The mass phobia of GOTO has always been unfounded. A GOTO is a valid way of exiting any logical block of code, but should never be used to enter a logical block. Unconditional jumps are in the machine code for valid reason.
I never saw computer scientists learning or using FORTRAN. It is used mainly by scientists and engineers.What kind of online communities do hardcore fortran-77 operations research type folk hang out?
Computers are created to do real useful job, not only to run compilers. Same for elegant algorithms.When writing compilers, you learn to really hate goto statements. They produce one hell of flow graphs and make it hard to use elegant and fast algorithms for register allocation, loop optimization, ...
Complexety invites in bugs, that goes for complex plans, complex algorithms and complex control flow. I have seen code ridden with a plaque of gotos, where the flow graph (in pencil on a chain printer stack of dead trees) looked like your 3yo threw spaghetti on the wall. Finding out why that thing did something was almost impossible. Whatever time was saved by the nest of gotos was eaten 10 fold in debugging that mess.Computers are created to do real useful job, not only to run compilers. Same for elegant algorithms.
Complexety invites in bugs, that goes for complex plans, complex algorithms and complex control flow. I have seen code ridden with a plaque of gotos, where the flow graph (in pencil on a chain printer stack of dead trees) looked like your 3yo threw spaghetti on the wall. Finding out why that thing did something was almost impossible. Whatever time was saved by the nest of gotos was eaten 10 fold in debugging that mess.
OK. But I hope you make difference between "plague of gotos" and using goto once per 3000 lines. Is a "while ( 1 ) {... break;...}" loop better optimized than single goto with the same logic?I have seen code ridden with a plaque of gotos, where the flow graph (in pencil on a chain printer stack of dead trees) looked like your 3yo threw spaghetti on the wall.
Sure, but in many a case where I see a goto I see that it is not needed and, in fact, produce worse code. There are places a goto is the only way, but it is a tool. You can not hand any tool to everybody and expect them to be equally skilled with that. I usually explain different ways to do things to the developer, and I usually request a good comment explaining why a goto is the way to go in that place, should you really need it.OK. But I hope you make difference between "plague of gotos" and using goto once per 3000 lines.