![]() |
Php5.3:: Goto...wtf???
PHP5.3 comes with lots of great improvements: namespaces etc...but it also comes with GOTO statements (reminds me of back in the day of BASIC), certainly not an improvement as this is open to abuse by a lazy developer who could easily create unmanageable code!
Ahhhhhhh.....!!!!! Note to PHP contributers: Lets improve PHP's multi-threading and daemonisation NOT f**king GOTO statements (even if they are improved GOTO statements)! |
Argh!! GOTO ... just ARGH!
A little pic we have on the Tech team page of our intranet (oddly it seems to be on the PHP manual too!): http://xkcd.com/292/ All joking aside, people criticize PHP for including it, when many respected languages implement them in one way or another. C for example has had it since the dawn of time (literally) and that's the most respected language you can find. It may surprise people that we have had types of goto in PHP for years, switch/break etc etc. PHP Code:
http://kerneltrap.org/node/553/2131 What's good for Linus is good for all! Quote:
|
Quote:
|
There is no "good" use for goto. Absolutely needing to use it means you don't understand structured programming.
|
There aren't alot of cases where you absolutely need to make use of any one particular feature in a language to accomplish a single task, we've many tools to accomplish the same thing. Goto's are just another feature and if we feel the need to use it than we may and if the code goes spaghetti, it's the programmer's fault and nothing to do with the existence of "goto" a sphagetti-coder will produce the same mess regardless of the existence of goto.
|
Quote:
|
goto in php isnt THAT bad, its a construct to ease development, in php its refered as the "jump label operator", but it really is a kind of goto but limited. In PHP you cannot jump inside a loop or to another scope for example. If you don't like it, then fine don't use it, simple as that. Rasmus have some slides and theres various videos with "Whats new in 5.3" by him, where he greatly explains it, what it is, what its not etc.
However goto is useful in some cases, for example when writing complex parsers, like the Engine which basiclly is a skeleton filled with rules thats turned into a complex parser with goto using tools like flex or re2c. So its a useful construct for such generated code for example. Quote:
|
It's not really all that bad, just don't use it if you don't like it. I can see how it would promote bad code practices, but I can also see how it would be useful for something like a multi-level break.
PHP Code:
|
Quote:
Well said! Basically...a note to everyone (including myself), dont produce bad code :-P |
| All times are GMT. The time now is 03:17 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0