Author | Message | ||||||
---|---|---|---|---|---|---|---|
goto c++
| I've heard many bad remarks on the goto statement.. I was just wondering if anyone on here feels like it is useless or would rather use a different statement in its place if they could? I like it myself for its flexibility and ability to jump out of loops back or forward to a designated point!
|
Re: goto c++
| I'm ok with it, but never really found a use for it that I couldn't do in other ways. You have to be careful with goto depending on what you use it for.
|
Re: goto c++
| It's handy to use and good for jumping back and forth like you said^^
|
Re: goto c++
| How did I miss this topic. I passionately hate goto in high level languages. The entire point of goto is to do a jump, which is an assembly instruction, which if you want to do the compiler's job for it, why not write in assembly? Or your own compiler! I'm also a Djikstra fanboy though, and he wrote a paper back in the sixties on why goto is a bad idea. I tend to agree with him on a lot of things and he's my hero for coming up with shortest-path-first. I think there is good use for it in C as an error trap mechanism, it makes code very readable in that way: if(statement1) goto error1; else if(statement2) goto error2; error1: /* handle error 1 accordingly */ error2: /* handle error 2 accordingly */ I also see it in a lot of production code, and a lot of non-academics are like "yeah whatever it's fine". HOWEVER - in spite of both these things I think that using goto is a sign that your code needs to be written better. Overuse can lead to very hard-to-follow code. On a totally and completely separate note, I also strongly dislike the 'var' keyword in strongly-typed languages (looking at you, C# >.<), unless you're using it with the keyword 'new', ie var list = new List<StupidlyLongTemplateClassNameIDontWantToTypeOutTwice>(). Otherwise it makes code stupidly unreadable because you have no idea what types things are. --- class EOSERV { Programmer | Oldbie Open source EO Client: https://github.com/ethanmoffat/EndlessClient }; |