|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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:
So, what do YOU think? |
|
#2
|
|||
|
|||
|
RE: Should PHP have goto statements?
I completely agree with your entire statement, Matt.
|
|
#3
|
|||
|
|||
|
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.
|
|
#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:
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? |
|
#5
|
|||
|
|||
|
RE: Should PHP have goto statements?
|
|
#6
|
|||
|
|||
|
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? |
|
#7
|
|||
|
|||
|
RE: Should PHP have goto statements?
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. |
|
#8
|
|||
|
|||
|
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...(?) ??? (GOTO baaaaaahhhh...I dont even like to use exit()!) |
|
#9
|
|||
|
|||
|
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). |
|
#10
|
|||
|
|||
|
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:
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.. |
|
#11
|
||||
|
||||
|
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. Quote:
Written a .bat file lately? |
|
#12
|
||||
|
||||
|
RE: RE: RE: Should PHP have goto statements?
Quote:
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:
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. |
|
#13
|
|||
|
|||
|
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?
|
|
#14
|
|||
|
|||
|
RE: RE: Should PHP have goto statements?
Ok fine. Dont put it in, Sheesh.
Quote:
Will this involve any federal grants or tax dollars? If not, by all means. |
|
#15
|
|||
|
|||
|
RE: Should PHP have goto statements?
Why not just use switch statements in a function call??
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Programming Theory > Should PHP have goto statements? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|