4 ms·
I'm going to upgrade immediately so I can use goto. Why am I being downmodded? I'm quite serious. I think it'll help clean up some of my previous PHP code.
by Oompa 17y ago
I'm going to upgrade immediately so I can use goto.
Why am I being downmodded? I'm quite serious. I think it'll help clean up some of my previous PHP code.
- emullet 17y agomy thoughts exactly
- smanek 17y agoThere are dozens of valid reasons to hate PHP. I don't know why everyone keeps picking on GOTO though. There are situations where it is the clearest and most concise way to express what you want (in modern times we emulate this functionality with continuations, exceptions, etc. because of the stigma attached to to GOTO). See http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pd... for a few examples. Lots of perfectly respectable languages (Scheme, Lisp, C-Sharp, etc) have GOTOs in some form or another. Yes, you can abuse them, just like you can abuse functions, methods, objects, or anything else.
- Oompa 17y agoI'm not hating, I think it'll help clean up my PHP code. Just like you said, there's nothing wrong with GOTOs unless they're abused, just like any other language feature.
- aceofspades19 17y agoHow would gotos clean up your code?
- pmjordan 17y agoThey can be extremely useful in error handling. They're also great as a substitute for labeled break statements if your language doesn't support them.
- aceofspades19 17y agoWhat ever happened to exceptions, which were explicitly invented to handle errors
- pmjordan 17y agoYeah. Turns out they're no silver bullet either. These days, my approach is pragmatic: use whatever works and produces the most readable code.
- Nycto 17y agoI, and probably a lot of other developers, have an immediate, negative, visceral reaction to "gotos". The reason is simple: If a language provides the appropriate control structures, gotos aren't needed. They will only make your code soupy. In my opinion, if you find yourself using a goto, you should be seriously reconsidering your design. This article was posted a little while ago, and I thought it gave a very good, non-partisan account of gotos: http://david.tribble.com/text/goto.html http://david.tribble.com/text/goto.html