Goto in PHP
Moderator: General Moderators
- volomike
- Forum Regular
- Posts: 633
- Joined: Wed Jan 16, 2008 9:04 am
- Location: Myrtle Beach, South Carolina, USA
Goto in PHP
Two thoughts for you to think about:
http://www.php.net/~derick/meeting-note ... dding-goto
http://xkcd.com/292/
http://www.php.net/~derick/meeting-note ... dding-goto
http://xkcd.com/292/
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Goto in PHP
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Goto in PHP
There are rare occassions where GOTO would result in a more elegant solution, IMHO. Just as inheritence and MI can be abused, so too can any programming contruct or control structure.
It's the responsibility of the developer to make effective use of each tool, right? Or maybe not. Perhaps it's the language that should barricade the developer and do everything it can to prevent the individual from making a mistake.
I suppose that is what HLL's are all about...making it easier to develop software all the while making it more difficult to shoot one self in the foot.
I have honestly never thought of it that way...huh...
It's the responsibility of the developer to make effective use of each tool, right? Or maybe not. Perhaps it's the language that should barricade the developer and do everything it can to prevent the individual from making a mistake.
I suppose that is what HLL's are all about...making it easier to develop software all the while making it more difficult to shoot one self in the foot.
I have honestly never thought of it that way...huh...
Re: Goto in PHP
I hope for the love of god this is not implemented.
- volomike
- Forum Regular
- Posts: 633
- Joined: Wed Jan 16, 2008 9:04 am
- Location: Myrtle Beach, South Carolina, USA
Re: Goto in PHP
Or we'll get eaten alive by raptors.
Re: Goto in PHP
Elegant? Subjective. more elegant [than objects], no. I used to program with gotos on a 2" by 1.5" Texas instruments screen in school, trust me it sucks. Objects are the same thing but your code doesn't depend on ordering, and you can pass parameters, etc... ( could go on and on )PCSpectra wrote:There are rare occassions where GOTO would result in a more elegant solution, IMHO. Just as inheritence and MI can be abused, so too can any programming contruct or control structure.|
Reminds me of http://www.dailymail.co.uk/news/article ... tions.htmlThe name "goto" is misleading, and often associated with BAD THINGS(tm). Because our proposed solution is not a real GOTO construct, we will instead reuse the "break" keyword, and extend it with a static label.
Next let's replace the word "gun" with "rose" so people will stop killing.
Re: Goto in PHP
Believe me - it's far more elegant than using jmp, je, jl, ja, etc. 8086 instructionsjshpro2 wrote:I used to program with gotos on a 2" by 1.5" Texas instruments screen in school, trust me it sucks.
Anyway, all of us use PHP-GOTO-like-statements:
include/require(), function calls, return, if/else, switch, break, continue, etc.
Yesterday, I had to debug some spaghetti code - there were 5 includes() (and iframes were used) to render a simple view in the last one. It's a GOTO and I hated it!
There are 10 types of people in this world, those who understand binary and those who don't
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Goto in PHP
I don't agree with the addition. It'd shorten certain code, but it's a lot more bug-prone, and unnecessarily so. We should be encouraging new programmers to think more in the direction of Java and C# than C and assembly.
Re: Goto in PHP
But still they need to have some C and assembly knowledge, IMHO.superdezign wrote:We should be encouraging new programmers to think more in the direction of Java and C# than C and assembly.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Goto in PHP
Agreed.VladSun wrote:But still they need to have some C and assembly knowledge, IMHO.superdezign wrote:We should be encouraging new programmers to think more in the direction of Java and C# than C and assembly.
Everybody should have to endure some of that nonsense if only to appreciate the beauty of OOP.
My only C and Assembly experience has been at uni programming ARM assembly and some simple graphics stuff using GLUT but I hated it xD Now I like Java even though I used to think it was stupid.
Re: Goto in PHP
Well I mean technically functions are "GOTOS", theyre just better "GOTOS", objects themselves are like a GOTOs, so are switches / and any other "control" constructs - my question is just what benefit does this new construct provide that the old ones don't cover already? How is it more elegant, in what situations? If by more elegant you mean harder to read but saves you 2KB of source code then I agree
Re: Goto in PHP
In my opinion, a GOTO in the traditional sense is reuse without scope. This is dangerous, like using a global, but can be used to solve difficult problems very easily (but not elegantly - in my opinion). I liked though the loop example they had in that discussion volomike linked to, that could be a nice addition.
Re: Goto in PHP
Agreed! I can't say it in a better waypytrin wrote:In my opinion, a GOTO in the traditional sense is reuse without scope.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Goto in PHP
Maybe im not geeky enough, but i haven' seen a funny one yetChris Corbyn wrote:I love xkcd.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Goto in PHP
A lot of people don't realise this, but sometimes the joke is in the title attribute so you need to mouseover it after you've looked at the comic.JayBird wrote:Maybe im not geeky enough, but i haven' seen a funny one yetChris Corbyn wrote:I love xkcd.