Re: Problems w/ goto
| From: | larry@garfieldtech.com | Date: | Fri, 17 Dec 2010 18:05:03 +0000 |
| Subject: | Re: Problems w/ goto | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310118@lists.php.net to get a copy of this message | ||
On 12/17/10 11:57 AM, Steve Staples wrote:
It's really a labeling problem. Goto usually refers to "jump to arbitrary line", at least when used in the vernacular. That's horribly bad and evil. What PHP has implemented is "named break statements", as I understand it. Those are not inherently evil. It doesn't break program flow any more than an exception does, but it's useful for non-error-handling cases. However, it reuses the keyword "goto" which is easy to confuse with the abomination above. It was a rather poor choice of name, frankly. --Larry GarfieldOh, i can see where it would be useful, i just hadn't realized it was still in existence... and the cartoon, was blown up, and put in my cubical :) RAWR!!I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto SteveI was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. When used properly within a well defined scope and with well named labels, GOTO can be a superior choice. If you think GOTO doesn't exist in many types of software, you need only grep for it in the C source code for PHP, MySQL, and Apache. Cheers, Rob.