News for hackers. Stuff that matters.
Re:PHP introduces "goto" by encoderer on Tuesday June 09, 2009 @03:36PM (#649776)
while() loops are just goto's with some syntactic sugar..
Re:PHP introduces "goto" by jcsalterego on Tuesday June 09, 2009 @03:38PM (#649786)
While loops are restricted gotos with syntactic sugar.
Re:PHP introduces "goto" by ComputerGuru on Tuesday June 09, 2009 @03:59PM (#649841)
Now that I come to think of it, it actually doesn't matter for PHP.

While loops limit the scope of variables inside the loop. For C++, that means a variable declared inside cannot be used outside - logical, and OOP.

But PHP has no concept of privacy or scope, even its "rules" may be broken (though not guaranteed to always work) and come out with the right results. Anything will compile, and usually the results are as expected.

So if you have a while loop with no concept of scope or local variables, I guess the restrictions are gone. A number of nested loops with breaks; and continues; all over end so long as the concept of limited data scope/access is not present as in PHP are exactly equivalent to goto as it is.

I guess a language as, shall we say, 'relaxed' as PHP is well-matched with relaxed keywords like goto.

Re:PHP introduces "goto" by pbiggar on Tuesday June 09, 2009 @07:01PM (#650179)
No, thats not what he means. He means that gotos are unstructured, and you can do anything with them, like jumping into a loop.

Although, PHP's gotos don't allow they, and PHP still only admits structured control flow.