Justin Patrin wrote:
Robert Cummings wrote:

Goto <line number> is a very broken way of coding. Goto <label> is a
very useful and structured way of coding especially when creating fast
FSMs for parsing. I was a little disappointed a few months ago when I
found that PHP didn't support  the goto label syntax since it would have
provided the most elegant solution.

goto anywhere is broken. For instance, goto-ing out of loops and functions, or into one function from another causes untold grief to the language developer and makes it very hard to read the code. Then there's using goto into and out of class functions, which is even worse.

In truth, goto has no place in a higher level programming language. Anything that can be done with goto can be done without it and (IMHO) more elegantly.

Robert, I know your grief, been there, I know how it feels. I started my childhood with BASIC, which was /the/ "GOTO" programming language, learned Turbo Pascal when I was a teenager, and continued to use GOTO's (Pascal discourages but doesn't disallow GOTO's, so I was still able to "cheat" when "there was a need for it"). Well, later on when I started finding out how major projects are being developed, what structured programming really means and so on, I felt the way you feel now: cheated. "Why in God's name is GOTO bad? It's SO useful! They're mad!" Well, it simply isn't true -- the problem is that you have to change your mindset about programming, try to really structure the way you see a program, break it into efficient stand-alone functions, group those in classes, etc, and you'll see that there *is* no need for GOTO, ever. You do need to break out of loops, you do need to "short" a loop when a condition is met, you do need to break out of switches, if branches and the lot - but those tools you have in PHP. GOTO is not needed and harmful. Even simply learning to program without GOTO will coerce you into saner code.


Sorry if my message sounded melodramatic or something, I remembered the frustration feeling so strongly from your message that I wanted to reinforce the other people's messages with a personal "testimonial" if you wish.

Bogdan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to