despite all the bs goto gets from all the wanna-be, amateur programmers
and their silly professors, it comes quite handy when you are working
on some heuristic algorithm prototype
and you just wanna break free from all the loops, conditions, recursions etc.
and debug the damn thing
No, because my professors don't grade papers, and neither do his TAs, they hire readers to.
Name:
Anonymous2012-03-10 23:52
>>7
If you need [b]goto[b] to do that then you have a design problem.
The only valid use of goto is error handling, so the amount of cleanup code grows linearly instead of quadratically with every allocation that needs cleanup.
Name:
Anonymous2012-03-11 0:02
>>7
See >>9 and learn how to use a debugger. Always use conditionals and flag to break out of a loop if you don't have a compelling case to do otherwise.
Name:
Anonymous2012-03-11 0:09
>>4
Please you child, it's Fundamentals of Programming, not Intro to Programming. You need to learn to not be so pretentious.
>>12
All I see is: I'm not going to maintain this shit, the maintainer can go get fucked.
>>14
Of course it's possible. It's also easier to track and debug the flow when you flag events that have happened.
Name:
Anonymous2012-03-11 9:01
>they're not reliazing that breaks and flags are just [code]goto[/cpde]
Name:
Anonymous2012-03-11 9:06
>>18
Of course that's what it gets translated to. The point is about having properly structured code for the language. If you're not going to structure it properly, you may as well return to pure assembly programming.
VIPPER said "working on some heuristic algorithm prototype". if VIPPER is anything like me, they hack together some horrendous code that simply works, and then refine it over a few iterations. in such a case i don't see problems with goto.
Name:
Anonymous2012-03-11 11:04
>>20
Hence why you always, and always will, work at places like Burger King.
>>23
I assure you I am not >>21, and given how unbecoming of you it would be to unscientifically and ultimately destructively belittle >>20 as >>21 did, I must conclude that it is none other than the Sussman who is accusing me of being a sockpuppet.
Please don't do that.
Name:
Anonymous2012-03-11 15:20
>>23
YOU FUCKING FAGGOT RETARD. I made one of those posts and neither of the others. Stop pretending you are a mod, or actually know shit about anything. You are such a fucking idiot. I love it when stupid faggot little dipshits with tiny dinks like you do those "Same person" line-ups and are totally wrong. Suck my big hairy cock you pathetic know-nothing little queer bait. I'll make you wear a fucking dress. What a stupid fag you are. hard to believe. Fag.
Name:
Anonymous2012-03-11 15:46
You can do whatever the fuck you want if the code is just for yourself. Goto works. Fuck you.
>>17
That's true. As long as the flag variable is only used to signal one event, you can use it as an indicator for that event. When one uses gotos, the context is given by the program counter. It's like, if you have reached this label, then this is a list of events that could have resulted in the program counter reaching this position.
But the only real solution is to keep your functions small. Having to keep track of 30 flag variables will be no fun. If it is contained within a well tested, well defined, and well documented function, then you don't need to keep track of its internal state, nor interact with it in any way.
Name:
Anonymous2012-03-11 17:03
>>25
Same man. Only white heterosexual cis-men can be so misogynistic.
GOTO is a perfectly valid C program construct. Is is there for a reason. Besides, C has many other features that are not taught and/or illustrated during college lectures.
GOTO and the GNU extension 'label values' are the most strongest tools I know for state machines, both hand written as machine generated.
If you haven't seen code like
void func(void)
{
__label__ L1, L2, L3;
void* states[] = {&&L1, &&L2, &&L3};
L1: /* state1 */
goto *states[nextstate()];
L2: /* state2 */
goto *states[nextstate()];
L3: /* state3 */
goto *states[nextstate()];
}
or haven't sniffed anything with regards to advanced CPU/hardware emulators, then you're really too inexperienced to claim anything about the validity of existence and usage of GOTO and it's friends.
Name:
Anonymous2012-03-11 20:04
>>32
Why couldn't that be replaced with a switch-case? It would look much nicer.
>>35 >>36
You have clearly never worked with artificial intelligence agents or databases. Every bit of performance counts in those fields. If you were writing business software or applets I would agree.
>>34
switch statements are often a bounds check followed by a jump to an code pointer indexed in an array table. But it would be nice if C provided a switch statement construct where the default case was undefined. I'd use it.
>>38 default case was undefined. switch (x) {
case 1:
case 2:
default:*(char *)NULL; /* u mad, bro? */
}
Name:
Anonymous2012-03-12 3:11
>>34
Switches are typically much more efficient than several if tests since they're far easier to optimize.
Besides if you use goto for retarded shit like jumping out of loops you'll suddenly have a really hard time parallelizing your code, which is just one of the many reasons it's typically banned at large companies where performance and maintainability matters.
I guess it's fine if you write shitty little toy projects where you think it's cool to use goto or something childish like that, but the cost seriously outweigh the benefits if you encounter real world problems, there are only a very few specific corner cases where it's acceptable.
>>41
Yeah I'm so hurt by someone else using goto in their shitty projects that will never be worked upon by anybody else. Oh yeah you're totally right it's so painful to me.
>>40
To put it simple, if you are on a level that could be considered advanced, and you cannot cope, handle, define, implement or at least understand why goto is present, especially if you are trained in computer algorithms and/or architectures, and the real-world arguments presented are brushed away with a tone equal to "you can program everything with just a for(;;) loop, so ban do{}while() and while(){}, then..., well..., I guess you are forcibly narrow-minding yourself to a degree considered ignorance is bliss.
There are levels where the usage of goto are preferred and which can be argued. But to kill this language construct just because it is not applicable in your field, or to ban lecturing of it because you see no sense or practical usage for it, and using arguments that reflect insufficient knowledge of truly advanced computer science is more like wasteful language purism.
Some people just need to set the standard. I'm fine with that, but please don't restrict or ridicule the advanced levels.
Name:
Anonymous2012-03-12 4:26
Why is do-while warrant disapproval?
Name:
Anonymous2012-03-12 4:50
>>44 There are levels where the usage of goto are preferred and which can be argued.
Did I say anything else? I mentioned some specific usage and said using it in those circumstances is stupid as shit.
Why do you think I said "there are only a very few specific corner cases where it's acceptable."?
Oh that's right, you can't read, because you're stupid as shit, go back to grade school you fucking retard.
Name:
Anonymous2012-03-12 5:34
>>45
Because it looks annoying and is unscientific and blah blah blah.
Name:
Anonymous2012-03-12 18:01
Goto is hated because it was used in BASIC and the professors felt that their ivory tower was threatened, so they condemned it in favor of stupid LIthP shit.
Name:
Anonymous2012-03-12 18:37
>>48
i thought dijkstra didn't like lisp either. actually didnt he pretty much not use computers