Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

using goto and do-while loops to annoy prof

Name: Anonymous 2012-03-10 23:32

Does anyone else do this?

Name: Anonymous 2012-03-10 23:36

no, because I don't like getting bad grades

Name: Anonymous 2012-03-10 23:37

considering my prof is an old-folk who probably learned C the hard way. I think he is used to that

Name: Anonymous 2012-03-10 23:39

>>1
No, because we already passed our 'Intro to Programming' courses.

Name: Anonymous 2012-03-10 23:45

Why would I want to annoy her? She knows how to teach properly.

Name: Anonymous 2012-03-10 23:45

I use goto and do while for their respective purposes, my professor doesn't dislike that.

Name: VIPPER 2012-03-10 23:45

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

careful kiddies

Name: Anonymous 2012-03-10 23:46

No, because my professors don't grade papers, and neither do his TAs, they hire readers to.

Name: Anonymous 2012-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: Anonymous 2012-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: Anonymous 2012-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.

Name: VIPPER 2012-03-11 0:16

>>9
>>10

ok kiddies read this carefully >>7
take your time

Name: Anonymous 2012-03-11 1:33

all my profs told their classes if you use goto's you will get 0's

Name: Anonymous 2012-03-11 5:22

>>10
loops and flags can easily become just as difficult to maintain as a bunch of scrambled gotos.

Name: Anonymous 2012-03-11 6:08

>>1
What if I use LAMBDAs and CALL/CC?

Name: Anonymous 2012-03-11 7:02

I use Goto because I'm fucking well ard m8

Name: Anonymous 2012-03-11 8:55

>>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: Anonymous 2012-03-11 9:01

>they're not reliazing that breaks and flags are just [code]goto[/cpde]

Name: Anonymous 2012-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.

Name: Anonymous 2012-03-11 9:11

>>17

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: Anonymous 2012-03-11 11:04

>>20
Hence why you always, and always will, work at places like Burger King.

Name: Anonymous 2012-03-11 11:07

>>21
I agree. >>20 is clearly a mental midget.

Name: Anonymous 2012-03-11 12:07

>>21
>>22
same poster

Name: >>22 2012-03-11 12:39

>>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: Anonymous 2012-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: Anonymous 2012-03-11 15:46

You can do whatever the fuck you want if the code is just for yourself. Goto works. Fuck you.

Name: Anonymous 2012-03-11 15:47

>>25
lol same person nerd.

Name: Anonymous 2012-03-11 16:38

ITT: EVERYONE BUTTMAD!!!

Name: Anonymous 2012-03-11 17:02

>>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: Anonymous 2012-03-11 17:03

>>25
Same man. Only white heterosexual cis-men can be so misogynistic.

Name: Anonymous 2012-03-11 17:21

>>30
Is must be a fat violent lesbian dyke.

https://www.youtube.com/watch?v=jV8j_U6s_1s

Name: Anonymous 2012-03-11 19:00

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: Anonymous 2012-03-11 20:04

>>32
Why couldn't that be replaced with a switch-case? It would look much nicer.

Name: Anonymous 2012-03-11 20:29

>>33
switch statements are just giant slow ifs


no thanks.

Name: Anonymous 2012-03-11 21:02

>>34
Performance is not a valid reason for shitty code. Besides that, we have tonnes of computing power today and maintainability should come first.

Name: Anonymous 2012-03-11 21:35

>>34

"Don't sacrifice sound architectural principles for performance."
Bloch.

Name: Anonymous 2012-03-11 21:37

>>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.

Name: Anonymous 2012-03-11 21:59

>>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.

Name: Anonymous 2012-03-11 22:43

>>38
default case was undefined.
switch (x) {
     case 1:
     case 2:
     default:*(char *)NULL; /* u mad, bro? */
}

Name: Anonymous 2012-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.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List