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

goto

Name: Anonymous 2011-12-15 15:55

why should i write:

while(faggot){
  ...
}

when it just gets turned into:

w1:
   if(faggot) goto w1e;
   ...
   goto w1;
w1e:
   ...

Name: Anonymous 2011-12-15 15:59

It's easier to read. That's pretty much the point of high-level languages like C.

Name: Anonymous 2011-12-15 15:59

I don't know, how about because:

1. It's shorter
2. It's more logical to read

Name: Anonymous 2011-12-15 16:08

>>2,3
Are you serious? The { } nesting bullshit is fucking obnoxious.

Name: Anonymous 2011-12-15 16:12

>>4
And to add the fact I can't use goto if the target address is inside one of those infinitely recursively kinky tangled jungles, makes me want to switch completely to asm.

Name: Anonymous 2011-12-15 16:18

>>4
CINP™1
_________________________________________
1: Acronym for CINP Is not Python, C is Not Python is not Python.

Name: Anonymous 2011-12-15 16:20

No one said you had to use C.  Aside from the massive supportive community and endless libraries.

Name: 4,5 2011-12-15 16:21

>>7
Yes, that's why I still use that bullshit.
Much like why I live on a rock orbiting a flaming ball of gas, it's not like I want to, it's because I have to.

Name: Anonymous 2011-12-15 16:26

>>8
Then shut yer gob. Use bindings for a different language or something. If it's for work, you're silly for complaining about having to do something you applied to do.

Name: Anonymous 2011-12-15 16:27

>>9
aww yeah gurl wanna suck my dick?

Name: Anonymous 2011-12-15 16:28

>>1
Because they're not the same. Loops can be split up, unrolled, or merged by the compiler as long as they perform as required by the C standard. They could use a fast compare-and-branch or increment/decrement-and-branch instructions, if possible, instead of setting flags or a condition register. if...goto hinders optimization and compile-time analysis and will make your code run slower in most, if not all, compilers. You also need to make sure there are no name conflicts in labels. That can easily become a jumbled mess of spaghetti code. If you have nested loops or move loops around, your system of w1:, w1e:, etc. labels could become unorganized. If you change the names, you might forget a label and have bugs without knowing why. C gives you looping constructs, so use them.

Name: Anonymous 2011-12-15 16:55

Note to all the faggots that use goto: it is a terrible programming practice, and the more you use it, the more you will fuck yourself.

Name: Anonymous 2011-12-15 17:00

>>12
Note to all faggots that use iteration: it is a terrible programming practice, and the more you use it, the more you will fuck yourself.

Name: Anonymous 2011-12-15 17:11

>>11-san, good job

  ∧_∧   ∧_∧   ∧_∧   ∧_∧      ∧_∧
 ( ・∀・)   ( `ー´)  ( ´∀`)  ( ゚ ∀゚ )    ( ^∀^)
 (    つ┳∪━━∪━∪━━∪━∪━∪━┳⊂     つ
 | | |  ┃This thread has peacefully ended.┃ | | |
 (__)_) ┻━━━━━━━━━━━━━━┻ (__)_)     Thank you.

Name: Anonymous 2011-12-15 17:45


  ∧_∧   ∧_∧   ∧_∧   ∧_∧      ∧_∧
 ( ・∀・)   ( `ー´)  ( ´∀`)  ( ゚ ∀゚ )    ( ^∀^)
 (    つ┳∪━━∪━∪━━∪━∪━∪━┳⊂     つ
 | | |  ┃This thread has VIOLENTLY RISEN.┃ | | |
 (__)_) ┻━━━━━━━━━━━━━━┻ (__)_)     FUCK you.

Name: Anonymous 2011-12-15 17:55

I'd like to take a moment to point out that >>1-san's code is wrong.  In fact, his two snippets are the exact opposite of each other.

Name: Anonymous 2011-12-15 17:59

>>16
everyone already noticed that, but no one other than you gave enough fucks to point it out.

Name: Anonymous 2011-12-15 18:09

isn't evolution great? It creates things out of nothing, and makes them automatically better! and on top of that, you dont hafta worry about it at all! it just works! AND IT'S NATURAL

Name: Anonymous 2011-12-15 18:25

>>17
ENOFUCKS

Name: Anonymous 2011-12-15 19:39

I only use gotos when I would otherwise use lots of flags. Like:


void fn(int* data, int iterations) {
  for(int iteration = 0; iteration < iterations; ++iteration) {
    for(x=0; x<W; ++x) {
      for(y=0; y<L; ++y) {
        if(iterationISdone(x,y,data)) goto done;
        ...
      }
    }
  done:
  }
}


Without gotos, this would likely be expressed as:


void fn(int* data, int iterations) {
  for(int iteration = 0; iteration < iterations; ++iteration) {
    int keepGOING = 1;
    for(x=0; keepGOING && x<W; ++x) {
      for(y=0; keepGOING && y<L; ++y) {
        if(iterationISdone(x,y,data)) {
          keepGOING = 0;
          break;
        }
        ...
      }
    }
  }
}


Although you could avoid gotos and flags by using a helper function, and returning from the helper function at an arbitrary point:


void performITERATION(int* data) {
  for(x=0; x<W; ++x) {
    for(y=0; y<L; ++y) {
      if(iterationISdone(x,y,data)) return;
      ...
    }
  }
}

void fn(int* data, int iterations) {
  for(int iteration = 0; iteration < iterations; ++iteration)
    performITERATION(data);
}

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