TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-06-2009, 07:39 AM   #1 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Unhappy 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)!
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
Old 08-06-2009, 10:16 AM   #2 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

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:
for($i=0$i10; ++$i)
{
    for(
$j=0$j 200; ++$j)
    {
        if(
$j == 20) { break };        
    }
}

switch(
$goto)
{
    case 
'cheese':
        
//do stuff
        
break;    

Did you know that the linux kernal uses extensive use of it?
http://kerneltrap.org/node/553/2131
What's good for Linus is good for all!

Quote:
this is open to abuse by a lazy developer who could easily create unmanageable code!
I totally agree, personally I don't much care for goto's I've seen some truly horrifying code using them, however I do still believe that is an issue with the programmer not the tool. A bad programmer will write bad spaghetti code irrespective of goto's availability. I have seen some equally as horrifying code without GOTO's.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 08-06-2009 at 10:27 AM. Reason: speeeeling
sketchMedia is offline  
Reply With Quote
Old 08-06-2009, 02:53 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
I do still believe that is an issue with the programmer not the tool. A bad programmer will write bad spaghetti code irrespective of goto's availability. I have seen some equally as horrifying code without GOTO's.
I'm definitely on this side of the fence. Goto in PHP is just another tool to get the job done; if poor programmers jump on every (mis-)opportunity to use this "new feature" then that is their problem and I hope you don't have to deal with their mess which would have been a mess anyway with or without goto.
Salathe is offline  
Reply With Quote
Old 08-06-2009, 03:18 PM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

There is no "good" use for goto. Absolutely needing to use it means you don't understand structured programming.
__________________

Village Idiot is offline  
Reply With Quote
Old 08-06-2009, 03:41 PM   #5 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

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.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 08-06-2009, 06:08 PM   #6 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Enfernikus View Post
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.
But goto is different, there is no good use for that command opposed to others that have lateral alternatives. I'm not saying that taking it away will fix coding, I'm saying it is bad to add because it can only hurt.
__________________

Village Idiot is offline  
Reply With Quote
Old 08-07-2009, 09:56 PM   #7 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

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:
Note to PHP contributers: Lets improve PHP's multi-threading and daemonisation NOT f**king GOTO statements (even if they are improved GOTO statements)!
If you want that improved, then post it to the mailing list, even creating a patch for it or see if others are interested in that feature, or put it on our bug tracker (bugs.php.net, mark it as a "Feature/Change Request"). Take a look at http://php.net/mailinglists and subscribe to internals and post a topic and see what others think, theres nothing like breaking the silence and stop complaing about features that may not appeal to you :)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 08-07-2009, 10:37 PM   #8 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

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:
// $x is a multi-dimensional array of data..

foreach($x as $y)
{
    foreach(
$y as $z)
    {
        if(
$z == 'your mom')
        {
            goto 
sweet;
        }
    }
}

sweet
Then again you could just use break 2; ...
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 08-08-2009, 09:01 AM   #9 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Quote:
Originally Posted by Enfernikus View Post
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.
Here here!

Well said!

Basically...a note to everyone (including myself), dont produce bad code
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:43 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design