RE: The "goto" discussion on the Internals List

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

 



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

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