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

Use goto

Name: Anonymous 2012-09-17 19:14

I'm using goto outside assembly and there's nothing you can do about it, meanwhile your jewish teachers gave your looping toys and forbid faster code for you.

Name: Anonymous 2012-09-17 19:25

goto is for idiots who can't figure out how to self-modifying code.

Name: Anonymous 2012-09-17 19:27

goto /g/, ``please''!

Name: Anonymous 2012-09-17 19:27

goto my anus

Name: Anonymous 2012-09-17 19:41

That's good. Now write some code.

Name: Anonymous 2012-09-17 19:43

Consider this: A pack of wild niggers

Name: Anonymous 2012-09-17 21:39

>>1
Can you point out an assembly language with goto? It's usually some abbreviation of branch or jump. I've seen b, br, bra, j, jmp, jump, and even mov to the program counter but I've never seen a goto mnemonic. I'd be interested to see what architecture that is.

Name: Anonymous 2012-09-17 22:12

goto >>8

Name: Anonymous 2012-09-17 22:26

>>7
PIC instruction set, but other than goto, call and sleep the rest of its three dozen mnemonics are things like btfss, iorwf and incfsz.

Name: Anonymous 2012-09-17 22:59

>>7
it's called fucking macros

Name: Anonymous 2012-09-17 23:22

>>3
I lol'd. Nice work, dude.

Name: Anonymous 2012-09-17 23:30

Very common idiom in kernel code:

int foo(int x)
{
    int status = 0;
       
    (void) bar(x);

    if (0 != baz(x)) {
        status = -1;
        goto out1;
    }
   
    (void) qux(x);
out1:
    unbar(x);
    return status;
}


This saves writing a stub function just to break out and unbar if baz fails.

Name: Anonymous 2012-09-17 23:35

>>12

I've used goto before, but it isn't that necessary here.


int foo(int x)
{
    int status = 0;
      
    (void) bar(x);

    if (baz(x) == 0)
    {
      (void) qux(x);
    }
    else
    {
      status = -1;
    }
    unbar(x);
    return status;
}

Name: Anonymous 2012-09-17 23:45

>>12,13
This is a simple example, so the value may not be immediately evident. Consider the case where qux represents a non-trivial amount of code - do you really want to nest all of it inside the else? Doing that is arguably less readable than just using goto.

Multiple nested elses also don't deal well with cases where you need to do a bunch of things in order and then back them all out if something goes wrong, e.g.


int foo(int x)
{
    int status = 0;
   
    (void) bar(x);
   
    if (0 != baz(x)) {
        status = -1;
        goto out1;
    }
   
    if (0 != qux(x)) {
        status = -1;
        goto out2;
    }
   
    (void) xyzzy(x);
   
out2:
    unbaz(x);
out1:
    unbar(x);
   
    return status;
}

Name: Anonymous 2012-09-17 23:57

>>14

ONE WORD. THE FORCED NESTED BRACKETING OF THE CODE. THREAD INDENTED OFF THE SIDE OF THE SCREEN.

int foo(int x)
{
    int status = 0;
  
    (void) bar(x);
  
    if (baz(x) == 0) {

      if (qux(x) == 0) {

        (void) xyzzy(x);

      } else {

        status = -1;

      }

      (void) unbaz(x);

    } else {

      status = -1;

    }

    (void) unbar(x);

    return status;
}

Name: >>15 2012-09-18 0:12

But I do use goto when I need to break out of nested loops.

Name: Anonymous 2012-09-18 0:21

>>14
[sage]HIBT?[/sage]

Name: Anonymous 2012-09-18 0:25

>>13
int foo(int x) {
  bar(x);
  int status = baz(x) ? -1 : (qux(x), 0);
  unbar(x);
  return status;
}


>>14
int foo(int x) {
  int status = -1;
  bar(x);
  if(!baz(x)) {
    if(!qux(x)) status = (xyzzy(x), 0);
    unbaz(x);
  }
  unbar(x);
  return status;
}

Name: Anonymous 2012-09-18 2:20

>>18
This.

Name: Anonymous 2012-09-18 7:17

I'm Java goto?

Name: Anonymous 2012-09-18 7:18

>>20
My word processor fucked up.

Name: Anonymous 2012-09-18 7:24

I use goto every time. I pitty the fools who use languages that don't have them. It's a legit language construct; don't be a pussy, with power comes responsibility. If Djikstra's so smart, why is he dead then?

/thread

Name: Anonymous 2012-09-18 8:48

goto
*grabs dick*

Name: Anonymous 2012-09-18 9:12

Name: Anonymous 2012-09-18 10:54

>>24
'
>lisp
>works

Name: Anonymous 2012-09-18 11:03

Name: Anonymous 2012-09-18 11:26

>>16
I use languages that let you break out of nested loops when i want to break out of nested loops.


100.times do |i|
  100.times do |j|
    break "``please''!"
  end and break
end

Name: Anonymous 2012-09-18 12:21

>>25`
>/b/
>you not going back to it

Name: Anonymous 2012-09-18 13:43

>>14
Thats when you use a maybe monad.

Name: Anonymous 2012-09-18 19:16

>>6
Consider this,
*grabs dick*

Name: Anonymous 2012-09-18 22:09

>>29
While we're suggesting to use features the language doesn't have: try ... catch also works for this.

Name: Anonymous 2012-09-19 3:27

>>31
And a maybe moand is so hard to implement?
You can easily implement it functioanlly with function pointers in c.

Here is a php example which operate on boolean directly, can be used to bind on functions that return a boolean to the maybe monad.
$simpleMaybeMonad = function($f) {
    return $f;   
};

$SMMbind = function($left_monad, $right_monad) use($simpleMaybeMonad) {
    if( $right_monad == false){
        return false;
    }
    else{
        return $simpleMaybeMonad($left_monad);
    }
};

$isTrue = function($abool){
    return $abool==true;   
};


$a1 = $isTrue(true);
$b1 = $isTrue(true);
$c1 = $isTrue(false);

$d = $bind($c1, $bind($a1,$b1));

if( $d == true){
    print("true");   
}
else{
    print("false");   
}


Here is with functions if you want to store functions and call the monad later on.

$maybeMonad = function($f) {
    return array($f, true);   
};

$maybeMonadFunction = function($maybe_a_monad) {
    return $maybe_a_monad[0];
};

$maybeMonadReturnValue = function($maybe_a_monad) {
    return $maybe_a_monad[1];
};

$bind = function($left_monad, $right_monad) use($maybeMonadFunction, $maybeMonad,$maybeMonadReturnValue  ) {
    $resultFunction = $maybeMonadFunction($right_monad);
    $result = $resultFunction();
    if( $maybeMonadReturnValue($right_monad) == false || $result == false){
        return array($maybeMonadFunction($left_monad), false);
    }
    else{
        $left_monad_return = $maybeMonadFunction($left_monad);
        return array( $maybeMonadFunction($left_monad), $left_monad_return() );
    }
};


$isTrue = function($abool){
    return $abool==true;   
};

$a = function()  { return true ; } ;
$b = function()  { return false ; } ;
$c = function()  { return true ; } ;
$aMonad = $maybeMonad($a);
$bMonad = $maybeMonad($b);
$cMonad = $maybeMonad($c);

$dMonad = $bind($cMonad,$bind($aMonad, $bMonad));
if($maybeMonadReturnValue($dMonad) == true){
    print("true");   
}
else{
    print("false");   
}

Name: Anonymous 2012-09-19 3:31

32 here, messed up the first example.
$isTrue = function($abool){
    return $abool==true;   
};

$a1 = $simpleMaybeMonad(true);
$b1 = $simpleMaybeMonad(true);
$c1 = $simpleMaybeMonad(true);

$d = $SMMbind($c1, $SMMbind($a1,$b1));

if( $d == true){
    print("true");   
}
else{
    print("false");   
}

Name: Anonymous 2012-09-19 6:14

Name: sage 2012-09-19 14:08

On some 8-bit computer:

> GOTO HELL
? Undefined line


As of late, I get to hear of
[code] while true { [code]
true is undefined
You can't handle the truth!

Name: Anonymous 2012-09-19 23:51

>>32
You can easily implement it functioanlly with function pointers in c.
Yes, clearly I should be doing indirect jumps every time I call a function in my driver code that could fail for any reason. Why didn't I ever think of this before.

here is a php example
Stopped reading.

Name: Python 2012-09-20 1:11

PHP IS LINE NOISE, YET STILL SLOWER THAN LINE NOISE.

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