Re: Problems w/ goto

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/17/10 11:57 AM, Steve Staples wrote:

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

Steve

I 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.

Oh, 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!!

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 Garfield

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux