Page 1 of 2
Goto in PHP
Posted: Mon Jan 05, 2009 2:32 am
by volomike
Re: Goto in PHP
Posted: Mon Jan 05, 2009 3:10 am
by Chris Corbyn

I love xkcd.
Re: Goto in PHP
Posted: Mon Jan 05, 2009 2:42 pm
by alex.barylski
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...

Re: Goto in PHP
Posted: Mon Jan 05, 2009 3:51 pm
by Benjamin
I hope for the love of god this is not implemented.
Re: Goto in PHP
Posted: Mon Jan 05, 2009 4:30 pm
by volomike
Or we'll get eaten alive by raptors.
Re: Goto in PHP
Posted: Tue Jan 06, 2009 1:28 am
by josh
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.|
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 )
The 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.
Reminds me of
http://www.dailymail.co.uk/news/article ... tions.html
Next let's replace the word "gun" with "rose" so people will stop killing.
Re: Goto in PHP
Posted: Tue Jan 06, 2009 4:59 am
by VladSun
jshpro2 wrote:I used to program with gotos on a 2" by 1.5" Texas instruments screen in school, trust me it sucks.
Believe me - it's far more elegant than using
jmp, je, jl, ja, etc. 8086 instructions
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!

Re: Goto in PHP
Posted: Tue Jan 06, 2009 5:20 am
by superdezign
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
Posted: Tue Jan 06, 2009 5:34 am
by VladSun
superdezign wrote:We should be encouraging new programmers to think more in the direction of Java and C# than C and assembly.
But still they need to have
some C and assembly knowledge, IMHO.
Re: Goto in PHP
Posted: Tue Jan 06, 2009 5:45 am
by mintedjo
VladSun wrote:superdezign wrote:We should be encouraging new programmers to think more in the direction of Java and C# than C and assembly.
But still they need to have
some C and assembly knowledge, IMHO.
Agreed.
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
Posted: Tue Jan 06, 2009 6:32 am
by josh
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
Posted: Tue Jan 06, 2009 6:44 am
by Eran
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
Posted: Tue Jan 06, 2009 6:51 am
by VladSun
pytrin wrote:In my opinion, a GOTO in the traditional sense is reuse without scope.
Agreed! I can't say it in a better way

Re: Goto in PHP
Posted: Wed Jan 07, 2009 1:41 pm
by JayBird
Chris Corbyn wrote:
I love xkcd.
Maybe im not geeky enough, but i haven' seen a funny one yet
Re: Goto in PHP
Posted: Fri Jan 09, 2009 5:49 pm
by Chris Corbyn
JayBird wrote:Chris Corbyn wrote:
I love xkcd.
Maybe im not geeky enough, but i haven' seen a funny one yet
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.