Goto in PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Goto in PHP

Post by volomike »

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Goto in PHP

Post by Chris Corbyn »

:lol: I love xkcd.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Goto in PHP

Post 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... :|
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Goto in PHP

Post by Benjamin »

I hope for the love of god this is not implemented.
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: Goto in PHP

Post by volomike »

Or we'll get eaten alive by raptors.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Goto in PHP

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Goto in PHP

Post 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 :mrgreen:

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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Goto in PHP

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Goto in PHP

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: Goto in PHP

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Goto in PHP

Post 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
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Goto in PHP

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Goto in PHP

Post 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 :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: Goto in PHP

Post by JayBird »

Chris Corbyn wrote::lol: I love xkcd.
Maybe im not geeky enough, but i haven' seen a funny one yet
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Goto in PHP

Post by Chris Corbyn »

JayBird wrote:
Chris Corbyn wrote::lol: 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.
Post Reply