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

goto considered harmless

Name: Anonymous 2018-05-10 11:02

I was reading Bjarne Stroustrup's sepples book and found this

One of the few sensible uses of goto in ordinary code is to break out from a nested loop or
switch-statement (a break breaks out of only the innermost enclosing loop or switch-statement).
For example:


void f()
{
int i;
int j;
for (i = 0 ; i <n ; i ++)
for (j = 0 ; j <m ; j ++) i f (nm [i][j ] == a ) goto found ;
// not found
// ...
found :
// nm[i][j] == a
}

Name: Anonymous 2018-05-12 9:29

>>10
Yeah, but now you have retarded `// not found` comment to document this stupidity. A separate function would do a better job at documenting this.

Also, what kind of retarded language doesn't have flat_map and filter or similar functions to do this kind of looping in single line?

The code in >>1 is very primitive and it is quite difficult for me to understand why experienced developer would write this. It is ok for someone who's been programming less than two years to do this stuff, but not for any serious developer.

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