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

goto, not much worse than break/continue

Name: Anonymous 2005-02-21 17:56

Discuss.

Name: Anonymous 2009-03-06 19:35

>>40
I saw the smoke all the way from the top of the /prog/ thread list. Massive burn

Name: Anonymous 2009-03-06 20:06

________♥
_______♥♥♥
______♥♥♥♥♥
♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
_♥♥♥♥♥_____♥♥♥♥♥♥
__♥♥♥♥_____♥♥♥♥♥
_♥♥♥♥♥______♥♥♥♥♥
♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
______♥♥♥♥♥
_______♥♥♥
________♥

Name: Anonymous 2010-05-24 18:40

bumping

Name: Anonymous 2010-05-24 18:58

>>42
JEWS

Name: Anonymous 2010-05-26 4:24

>>30

for (int y = 0; y < rows; ++y) {
    int all_zero = 1;
    for (int x = 0; x < columns; ++x) {
        if (matrix[x][y] != 0) all_zero = 0;
    }
    if (all_zero) return y;
}

Name: Anonymous 2010-05-26 4:30

>>45
here, better version


for (int y = 0; y < rows; ++y) {
    for (int x = 0; x < columns; ++x) {
        if (matrix[x][y] != 0) goto next_row;
    }
    return y;
next_row:
}

Name: Anonymous 2010-05-26 4:34

Is break considered the same as goto?

Name: Anonymous 2010-05-26 4:41

Why use goto when you can inline your entire program and not have to execute an extra jump instruction? I think this should be an optimizing feature enabled in gcc -O2 called --funroll-programs.

Name: Anonymous 2010-05-26 5:00

>>47
Every control-flow instruction is the same.
If/Else is a goto, all loops are goto's, and so on. Most control structures are implemented using jumps by the compiler. In languages where control-structures are defined using macros (see: Common Lisp for an example), you'll see that GO is frequently used to define such macros rather straightforwardly. Exceptions are ... not (just a ) GOTO's. Exceptions are more complex things, which involve stack unwinding, executing cleanup handlers, and non-local transfer of control - at the low level, the instruction pointer is always directly changed, just like jump (goto) instructions do.

Use go(to) when it makes sense, but only use it when other control-flow structures won't suffice or they look too ugly. If the language permits you to create new control-flow structures with ease and you need a more unique one, feel free to write it and use it. Go(to) is only bad when you reach for it before reaching for more suitable control-flow structures. Knowing when and how to use it is another useful programming skill. I can't remember the last time I had to write a GO in a real CL program directly - I've only used it in macros. As for C, I sometimes use it for error cleanup/handling and breaking out of multiple nested tight loops without invoking additional comparisons tests(performance reasons).

Name: Anonymous 2010-05-26 5:04

Linus Torvalds on GOTO:
http://kerneltrap.org/node/553/2131

Name: >>49 2010-05-26 5:05

Breaking out of such loops in CL is much easier done using standard special operators and doesn't really require GO at all, as for error handling - the condition system is one of the most advanced error handling mechanisms I've ever seen and one doesn't handle errors in the same crude way one does in C, so neither common GOTO usage case happens in CL - usually leaving it relegated to macros and building manual state machines.

Name: Anonymous 2010-05-26 5:43

Bitches don't know about my multi-process OS.
Enjoy your non-gotoing CLI.. OH, wait, that uses GOTOs as well!
Oh well, seems that GOTO haters are just full of hypocrisy.

In before people say it isn't, it is.  Just because it isn't called GOTO doesn't mean it isn't a GOTO.

Name: Anonymous 2010-05-26 7:01

>>50
God damn Rob is a massive faggot.
That use of GOTO isn't spaghettifying in the slightest.
It creates a logical separation of code, something that IFs make ugly when chained more than 2 levels deep. 
In fact, even in the "fix" Rob made was pretty god-awful.

Just as Linus said, GOTO can be used to minimize on code as well.  Not to mention cycles.
I had a program where i could launch a input box from a hotkey to go to a label or run a function.
Using a return statement of some form is just a waste of cycles and code.
GOTO is a logical jump in this case.  It goes to an unrelated section of code, runs it, then ends. 
If i were to have let it return to where it was originally launched from, i would have needed to write about double, maybe triple the code to deal with exiting.
Simpler, more efficient code > structured and longer code.
All those OOP people are especially bad at this, creating stupidly large structures of code for the fucking simplest of things.

Name: Anonymous 2010-05-26 10:09

C++ needs named breaks. Like ENTERPRISE language.

Name: Anonymous 2010-05-26 10:40

Name: Anonymous 2010-10-02 15:59

I love tea

Name: Anonymous 2010-10-02 16:30

>>6
Paw. Here is my response:
for (zomg = 0, blah; !zomg; blah) {
    blah;
    zomg += error;
    blah;
    zomg += error;
    blah;
    zomg += error;
}

if (zomg) {
    fprintf( stderr, "
HAX MY ANUS" );
}


It's never too late.

Name: Anonymous 2010-10-02 17:10

>>57
Does not generalize well and depends on error codes.
If your error codes are negative, positive or whatever, the sum can be unpredictable and this could even be exploitable by a malicious user. However, your idea can work in some cases. Here's a variation on it which will always work as long as success error code is 0 and any non-zero return code is an error:


anyerror = 0
...
anyerror |= op(...);
...
anyerror |= op(...);

if (anyerror)
  handle_failure(...);

Name: Anonymous 2010-10-02 17:13

>>58
which will always work as long as success error code is 0
No changes needed.

Name: Anonymous 2010-10-02 17:32

>>59
If your ``zomg'' variable is an int (signed), and one return value is -2, and two others are 1 and 1 (all errors), zomg would add up to 0 (as an example), and that fprintf would never run.

Name: >>60,58 2010-10-02 17:34

Or even if it was a unsigned int, you could have the same error codes: 0xFFFFFFFE, 1,1 on 32bit machine) and it would still add up to 0 due to integer overflow. The issue will never happen if you use OR(|).

Name: Anonymous 2010-10-02 18:06

>>57,58
What's the point of reporting the error afterward if you failed to abort at the moment it occurred?

Name: Anonymous 2010-10-02 18:54

you are now aware that you're posting in a thread from 2005

Name: Anonymous 2010-10-02 18:55

>>63
Good threads never die, they just deadlock.

Name: Anonymous 2010-10-03 8:27

>>62
That was the point. Although, it's fine as long as the lines don't depend on the success of previous statements.

Name: Anonymous 2011-01-24 16:52

Does race exist?

Name: Anonymous 2011-01-25 12:45

>>66
Yes. And you lost it.

Name: Anonymous 2011-02-03 2:49

Name: Anonymous 2011-02-03 8:16

Name: Anonymous 2011-03-02 21:30

I AM THE MOST FUCKING NGGER MATURE

Name: Anonymous 2013-04-18 16:58

25$ a poop !

Name: Anonymous 2013-04-20 17:54

check em

Name: Anonymous 2013-04-20 17:56

Not much worse, no.
But then, goto isn't that bad. It's just extremely easy to abuse it.

Name: Anonymous 2013-04-20 18:21

>>70
ASKFHSed?Gsdfghsdfkhgbafgbhbgfhbfs fukk sex you nigger cock pussy! i fuck yhou you have satan you canada ass whovdoesn't beleive in Christ! I HOPE YOU ALL GET RAPES!

Name: Anonymous 2013-04-20 23:33



Searching for legit Microsoft Product keys, Windows 8,7,Studio,Server etc.?

 Mail me at jeremiahgoldstein@hotmail.com

 25$ a pop


Searching for legit Microsoft Product keys, Windows 8,7,Studio,Server etc.?

 Mail me at jeremiahgoldstein@hotmail.com

 25$ a pop


Searching for legit Microsoft Product keys, Windows 8,7,Studio,Server etc.?

 Mail me at jeremiahgoldstein@hotmail.com

 25$ a pop

Name: Anonymous 2013-09-01 13:49



          ____       \
       r‐'7ヽ、 `ハ`二ヽ-、  ∠
    r-く  ヽ,>'"⌒ヽハ`ー‐くト、/
    _,!  ヽ/   /ハゝ/rヘ   ヽ.
    ! __,.ィ/   //'´  ,  ',ハ   ',
   rイ/   / 、 ハ ! /|  i ハ   ハ>
   ノイ / / ソ,!=ヽ、レ' | ./_,!イ!  i
  イ /!, ヘハ/ヘ!,_r:ソ`' レ' ト_ハ/!  i,
  〈イ  ハイ ハ 〃"    ,  〃!./|  ||>
  /ン / /レY〉.u  , ー‐-┐ ハ/レi/|\
 ,.イrく V  〈X!へ、 !_____ン,.ィ'|y〉ハヽ<
 ,.イ ̄7ヽ、〈Xト-、`>ーr<へィ二_ヽ、 、\,.、
 Y´ヽi、__/⌒y〉:::`'ーt-イ/::i 「i-‐-.、 i } }  V\/\/\
 !/:::::::::ヽ、 iヽ<:::`ヽ[_]':::::i l_!‐-- i〉、
./k:::::::::::::::::::ムヘ__>:::::::/ハヽ:::::::ゝ'ゝ_ノ i

Name: Anonymous 2013-09-01 13:54

break and continue are awesome, much better than only using fors and putting all your stop conditions with ors
plus, lua's fors don't have customizable stop conditions, they're just
for x=0,100 do
I don't find goto that bad too, but there are very few languages that implement it

Name: Anonymous 2013-09-01 15:19



               _,,.. -─- 、.,
            ,  '´          ` 、
          /                ヽ
        ., '    / /   、    \   ':,
        /    ., '   '     '  /`l '   ', 
       ;     /    |       |, ' /l | |  l__
       |    ' ;'  /'、   ト、 / /-‐ `'ー-<´r|
       |    !/-‐/ __ 、  | ∨    l    ∨        :
      、_.ノ    |!、ァ七7ヾ \| / lト、ヽ  、    ハ       ..:::..
      `7、   、ヘ 乂_.ノ  / 八 \\  .ノ |ゝ     ,. -─- 、       :
      ∠..-\  \"     '     \」   _,.‐ァ'| ...  /    丶*\     ..::..
      :.  | `ーハ      | ミヽ      ー'/ |!  :::... {  ノ   、_)   ',   :::  ::
     ..::   ,:|  | ム、  r 、   /`!、__ ` ニ./ 八    ', * ー'´ __  }   _,,,...,,,__
   ,. -─- /,'   ;/  |l≧ノ }/ /  _` ー./| /   ` ーァ  、   , 「  -─-<:::::::::::::l {
 /ー   -//  ,'_,,. イ∨ ´   /-‐'"ノ, イ ト、   `' 、   `/ニ=-::::::::::::::::::::`ヽ:::://
/  / .//;'   ;´  / .|     ‐''イ   |   ! \     ヽ ,'::::/!::::::;::::::;:::::::l::::ヽ:::::∨
  ‐、, ' /  {   .{ r-- }   _,,.イ´  ̄` ;  |/  ヽ.  \ |:::/メ/|::::/|:::ノ!:::::ハ::::::l
  ./  .{  ∧   \ヽ_」___{_r- =   /   '/   ',    レ'-r_ァ' レ 、_l二」:::/:::}:::::|> :
ヽ_ {   ' / ' 、  「´       `ヽ、, '   /´    |  , // "     ゝ-'レ'|:::/::::::l  ::
  ノ   l |   ,ハ /  !   /  //   イ      |//::{   `rー-‐ァ   "/_]:::/l::{ :::
   

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