On Tue, 2003-12-09 at 00:51, 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. > > > > Cheers, > > Rob. > > 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.
As I said that all depends on how it is used. Anyone can write unreadable code regardless of whether the language supports the goto statement. Also since PHP is strongly based on C, you'll notice that the C language does not allow cross function jumping via goto. Goto must jump to a label defined in the same function, so your second argument in this case is invalid. As someone who has implemented my own language, I can tell you I had absolutely no grief implementing a goto <label> system. > In truth, goto has no place in a higher level programming language. This is your opinion, please feel free to qualify it. > Anything that can be done with goto can be done without it and (IMHO) > more elegantly. Yes anything that can be done with goto can be done without, but the whether it is more elegant strongly depends on what your goal is and how that goal can be achieved. Here's something you should do to properly open your eyes to the utility of the goto <label> statement. cd /YOUR_PHP_INSTALLATION_SOURCE/ grep -rE 'goto [_[:alnum:]]+;' * In my installation alone there are 1522 instances of goto used. And really I don't consider PHP that much higher level a language than C, although it does provide plenty of high level functions. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php