Programming Theory
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesProgramming Theory

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 30th, 2004, 01:15 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
Should PHP have goto statements?

There is a rather large discussion going on in the PHP internals list right now regarding adding goto statements to PHP. It seems that most people are for it, though several core programmers have not voiced opinions at this point. Check out the patch being submited here:

http://news.php.net/php.internals/11599

Those that are against adding the goto statement argue that it would give newbie's an easy way to produce horrible code. While I agree this may be true, I don't think we should limit better programmers just because a newbie may not know how to properly use a goto statement. If we went down that line of thinking, we could eliminate plenty from the language.

I think Jason Garber (http://news.php.net/php.internals/11639) summed it up well with:

Quote:
There are PLENTY of way's to shoot yourself in the foot with any language. If joe shoots himself in his foot, does that mean that I should not be allowed to shoot at all?


So, what do YOU think?

Reply With Quote
  #2  
Old July 30th, 2004, 02:04 AM
zackcoburn zackcoburn is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 184 zackcoburn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Should PHP have goto statements?

I completely agree with your entire statement, Matt.

Reply With Quote
  #3  
Old July 30th, 2004, 03:24 AM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 12 sec
Reputation Power: 5
RE: Should PHP have goto statements?

I like the idea of goto. One word: CONTROL. No matter how horrible the code, the more control I can place into it, the better. It would introduce a nice "pointer" feature to PHP that it currently lacks. I think it would also do wonders to clean up the lenghty if/else or switch statements with tons of code in between. Easily managed, you dont have to search through tons of code, you just find its relative goto label and modify that. It would, for one, be easier on my eyes.

Reply With Quote
  #4  
Old July 30th, 2004, 10:59 AM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 4
RE: Should PHP have goto statements?

I've always thought GOTO statements were a crutch for poor code organization and abstraction (whether that means functions or objects).

Quote:
If we went down that line of thinking, we could eliminate plenty from the language.

That argument doesn't hold water: just because we've done things wrong in the past, doesn't mean we should do new things wrong.

PHP is often criticised as being inconsistent and too easily allowing newbies (or even experienced programmers) to write poor code. Adding GOTO statements isn't going to improve that image any. Granted, improving the image is not, and should not, be the goal, but I don't think adding fuel to critics' fires for no real reason is a good idea either.

How about adding a COME FROM statement?

Reply With Quote
  #5  
Old July 30th, 2004, 01:43 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to notepad
RE: Should PHP have goto statements?

having never worked with goto, how is that different from the heredoc statement? and honcho posted this link before, about why goto is bad..

Reply With Quote
  #6  
Old July 30th, 2004, 02:46 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Should PHP have goto statements?

Personally I think adding a statement like that to the core of the language is silly. If you need it, maintain it as a PECL package. That is the common practice now with anything new, is that it woudl be a package, then possibly brought into the PHP core.

Ultimately I do aggree that there is plenty wrong with implementations in the past. But that does not mean that bad code practices, or bad code should be introduced in the future.

Ultimately I don't care if this package is maintained, or even in PECL. Just don't force it on me by putting it in the core.

PHP has made great strides toward becoming a solid language with 5.0, why not keep the trend going?


Reply With Quote
  #7  
Old July 30th, 2004, 04:22 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 12 sec
Reputation Power: 5
RE: Should PHP have goto statements?

Quote:
Ultimately I don't care if this package is maintained, or even in PECL. Just don't force it on me by putting it in the core.


Who is forcing you to use it if it is there? My feeling is that if you don't wish to use it, dont.

Reply With Quote
  #8  
Old July 31st, 2004, 01:02 AM
~Bean~ ~Bean~ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: GA,USA
Posts: 42 ~Bean~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to ~Bean~ Send a message via AIM to ~Bean~
RE: Should PHP have goto statements?

Very interesting...

I am relatively new to PHP so my input may not be valued as much as long time users. I am a long-time programmer though...

This statement used to be essential (for some languages, i.e., BASIC, FORTRAN)...so I think GOTO had its place, but I haven't seen that place in quite some time. For years GOTO has taken a bad rap because it was 'unnecessarily' kept in some modern versions of certain "modular" languages, and always "gets misused by poor software design(ers)". I agree because I am of the belief that its use creates unstructured and hard to manage/debug large segments of code.

I think some folks here are expressing "why not?"...and not "why?", or it could be their "programmers civil rights"...{chanting)"Hell No We Won't Go...We'll GOTO!" (lol...**ahem**)
But I think also some folks are saying that anything you can do with GOTO (in PHP) you can probably do better some other way...soooo perhaps we should ask our pros who support the inclusion of GOTO to provide some (pseudocode) examples of how it is a great, or any, benefit in practical use or design...

or I guess what I am also asking is how does NOT having GOTO limit you?

Another question too (Matt), what is the proposed syntactical use of GOTO in PHP? like such...(?)
php Code:
Original - php Code
  1.  
  2. ...
  3. ...
  4. //Things are happening...
  5. //Uh-oh! Let's check if we need to get out of here...
  6. if (something is true)
  7. {
  8. GOTO Uncond;
  9. }
  10. ...
  11. ...
  12. etc.
  13. exit();
  14.  
  15. Uncond:
  16. echo "You have just experienced unconditonal flow -OUCH!";

???

(GOTO baaaaaahhhh...I dont even like to use exit()!)

Reply With Quote
  #9  
Old July 31st, 2004, 02:22 AM
bainer bainer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 47 bainer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Should PHP have goto statements?

If you can't control your flow with what's currently in PHP then there's something wrong with you. GOTO was great in the BASIC days when program flow was nothing but top to bottom - and yes I know PHP is much the same, but with all the control structures there are, one can easily imitate a modular flow without losing any capability.

GOTO has few, if any uses which aren't done better by the language already (as an obvious example, user functions).

Reply With Quote
  #10  
Old July 31st, 2004, 04:07 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: RE: Should PHP have goto statements?

AFAIK, goto is "considered harmfull" for a very long time..

when you posted this, i thought it was some joke.. in fact, i still think so.

i can't say what is wrong and what is right, but i think i can speak from my 10+ years of programming.

i started with basic. most of us did start with it in those days, and basic had "for" and subrutines (functions), and i don't think i used GOTO a lot..

anyway, some 11 years ago, i found about this pascal thing (that came before delphi). pascal didn't have a GOTO statement, and i know i never needed it. ever! not once, in 10+ years!!

when you think you need goto, it is IMHO a sign of a badly designed code.. rework it..

Quote:
Who is forcing you to use it if it is there? My feeling is that if you don't wish to use it, dont.


well, if you use it, and i come into the company after you, i still have to support (maintain, etc..) your code.. that is why i don't want you to use it..


Reply With Quote
  #11  
Old July 31st, 2004, 06:44 AM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 12 sec
Reputation Power: 5
RE: RE: Should PHP have goto statements?


Quote:
If you can't control your flow with what's currently in PHP then there's something wrong with you.

Can't is not the issue. Just another option in the mix. I cant see where I would use it currently, but one day, who knows, I may, just because thats the way I wish to do it. Yes, I am stubborn, I know I do not share the view of others.

Quote:
GOTO was great in the BASIC days when program flow was nothing but top to bottom -

Written a .bat file lately? Im not disagreeing, I am merely pointing out that it's still used to some degree.

Reply With Quote
  #12  
Old July 31st, 2004, 01:35 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 4
RE: RE: RE: Should PHP have goto statements?

Quote:
Can't is not the issue. Just another option in the mix. I cant see where I would use it currently, but one day, who knows, I may, just because thats the way I wish to do it. Yes, I am stubborn, I know I do not share the view of others.

I mentioned COME FROM as a joke, but can't this same argument be applied to it? If we get GOTO, why not get COME FROM? You don't have to use it if you don't want to, but the option will be there if you ever find you want to use it.

Quote:
Written a .bat file lately? Im not disagreeing, I am merely pointing out that it's still used to some degree.

We are not arguing that GOTO should not be in any language, just in high-level langauges, in particular, PHP. Last I checked, batch files used fairly low-level commands.

Reply With Quote
  #13  
Old July 31st, 2004, 02:11 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Should PHP have goto statements?

If the GOTO statement is added into the core of PHP, I will be forced to stop using the language; GOTO statements are strictly defined as immoral in my religion, and unethical in my business practice. Anyone who even considers using a GOTO statement should crumple in front of a firing squad before they get a change to implement such a monstrosity into an otherwise organized script. I am proposing the creation of an anti-GOTO committee, forged from the best and the brightest cornerstones of the PHP community. No GOTO, or no PHP! Who’s with me?

Reply With Quote
  #14  
Old July 31st, 2004, 02:25 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 12 sec
Reputation Power: 5
RE: RE: Should PHP have goto statements?

Ok fine. Dont put it in, Sheesh.

Quote:
I am proposing the creation of an anti-GOTO committee, forged from the best and the brightest cornerstones of the PHP community. No GOTO, or no PHP! Who’s with me?


Will this involve any federal grants or tax dollars? If not, by all means.


Reply With Quote
  #15  
Old July 31st, 2004, 02:32 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Should PHP have goto statements?

Why not just use switch statements in a function call??

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesProgramming Theory > Should PHP have goto statements?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek