Re: goto considered essential
- Posted by Al Getz <xaxo at aol.com> Jan 21, 2006
- 516 views
John E. Franklin wrote: > > How about a goto that only jumps down in the code, not back up to repeat. > Use loops to repeat: while or for loop. > But goto that jumps forward is good enough for Tom's example, but > prohibits spagetti code quite a bit. > Or have a jumpback command and a jumpforward command > to make the code easier to read and find where you > are going. > I personally like gotos because a really > smart guy whose code I used to read in C would only > return from a function at the end of it with > "return retval" usually, and he would jump to egress:, > which was a label prior to the end of a function. > Egress means to exit, so that's what he called it. > So that way you don't have two or more return statements > in one function. He set the retval and did "goto egress". > > Anyhow, a jump forward and jump back would be nice for me, but > I can stand the exit_loop statement, whatever it is, I just learned > Euphoria three days ago. Hi John, There's no goto in Eu because Rob (as well as many other people who have a lot of programming experience) believes that the resulting code is not as structured when using goto's, and that like Vincent had mentioned, it could lead to bad programming habits. The best you could do is break the code into sections and call each one from conditional statements, or use multiple returns to exit code from various points. I know some people dont like to use multiple returns (rather one return at the end so that everything that happens before the return is easier to see) but it seems to be essential to do this sometimes. Should it be up to the programmer to use 'goto' or not? I suppose so, after all the C compilers have it. Will Rob ever implement this into Eu? Who knows :) but probably not. Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"