You are here: RE: [PHP] The "goto" discussion on the Internals List « PHP « IT news, forums, messages
RE: [PHP] The "goto" discussion on the Internals List

Posted by Robert Cummings on 06/07/05 20:59

On Tue, 2005-06-07 at 10:50, Jay Blanchard wrote:
> [snip]
> Goto has (I believe) been described as a method of shooting yourself
> in both feet at the same time.
> [/snip]
>
> goto (not a 'new' construct as was mentioned earlier) had its uses, but
> thos would seem depricated now as you can call a function, which is
> essentially what a goto did. Consider;
>
> if('foo' == $bar){
> goto(1001); //essentially a line number (remember, old school)
> OR goto(LABEL); //defined constant
> } else {
> goto(2001);
> }

Absolutely nobody in this day and age advocated "goto <lineNumber>". The
only use to have useful advantage is "goto <labelName>" and of course
that is where the <labelName> exists within the current execution scope.

A function call is not an acceptable replacement since you incure the
overhead of setting up the function and the stack. Contrast the
difference in speed between "is_null( $foo )" and "$foo === null".

>
> VS.
>
> if('foo' == $bar){
> assimilate($bar);
> } else {
> anhylate($bar);
> }
>
>
> Where problems arose from goto they would arise from function use as
> well. Nesting goto's was every bit as challenging as properly
> constructing regex statements. goto also did not fit as well with OOP
> methodology, being more of a procedural construct in accordance with the
> procedural programming at the time that it was conceived.

PHP has never purported to be an OOP only language. It advocates both
procedural and OOP programming methodologies. Just ask Richard Lynch :)

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. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация