Thread #108297544
HomeIndexCatalogAll ThreadsNew ThreadReply
H
File: file.png (1.6 MB)
1.6 MB
1.6 MB PNG
>years of programming experience
>number of times you have used a "goto" statement
12
1
+Showing all 25 replies.
>>
>>108297544
42
hundreds. untold hundreds of thousands if you count BRx/JMPx in assembly. The dangers of goto are extremely overrated, jumping forwards in the code is pretty tame, the problematic uses of goto are things like jumping backwards into the middle of a control structure, or jumping from one procedure into the middle of another procedure (common hack in fortran and assembly). In modernish languages goto is mostly useful for getting out of deeply nested loops or other control structures, and for that it's pretty completely harmless - the alternative is putting those nested loops into their own function then returning from that function, which is functionally identical, and after inlining generates the exact same code, only now it's less readable than the simple goto version.
>>
do it all the time. just need to remember to pop the top of the stack afterwards otherwise there'll be a stack overflow.
>>
>>108297544
0
0
i dont even know what the fuck a goto statement is
>>
Do jmp instructions count in assembly? If so then I've got a lot more than I can remember. Otherwise it's 0.
>>
>>108297544
30
Countless. I started out with BASIC as a kid, and you can't write much in it without goto.
>>
>>108297544
13
idk
They're useful in C for cleanup on early exit. If you have a bunch of alloced data and you have conditional exit points, instead of returning when entering an if statement, goto clean up, where you have multiple tags depending on how many variables you need to free. Then the top tag is the for when max data has been allocated and the higher tags "fallthrough" to the lower tags. Prevents duplicate clean up within a function
>>
>>108297642
>nto the middle of a control structure, or jumping from one procedure into the middle of another procedure
C++ doesn't even let you do this tbqh

Midwits hate goto because they feel like expressing an emotional hatred for it will make people think "woah, this guy REALLY agrees with something Dijkstra once said (about a different language where the keyword meant something very different), he must be a godlike programmer!" It's basically just virtue signalling, like pretending you really hate Hitler even though your family was never even inconvenienced by Hitler in any way, because you think it'll make you seem like the best goy.
>>
>>108297544
13
0
>>
>>108298662
this
>>
>>108297544
outside of **extreme** hotpaths in embedded systems (i.e. packet processing) you should never use gotos.
>>
0
8

Fuck even I know the basic 10 print "nigger" 20 goto 10 ot whatever you just instantly type on every old pc you see
>>
>>108297544
IDK either desu. Maybe hundreds of gotos, mostly out of loops, to error handling slash cleanup code, and between case labels in a switch block.
>>
>>108297544
0
Infinity, because I looped a goto without end
>>
>>108297544
13
3 or 4
was still starting at the time and I didn't want to use while loops for some autistic reason
>>
>>108297544
over 9000
over 9000
>>
I just have other people do the coding for me and congratulate them on being legends. Then I take credit.
>>
>>108298912
And let's be honest, that's a fair deal.
>>
Loads. In Vb6, fpc, C++, batch. Gotos aren't bad, it's just a tool. Magic function calls used in scriptjeet slop (Laravel is so egregious on this) is FAR worse than gotos scattered in a unit file.
>>
>>108298662
>Dijkstra once said
Nar its even worse than that, they hate it cause they saw the xqcd comic on it calling it bad.
>>
>>108297544
I follow the C++ recommendations that state it's useful when you need to get out of an inner loop. This is the only time it's justified.
>>
>>108297544
only did during assembly glass, dropped it shortly after lul
>>
>>108297544
I used them a zillion times when I was a teenager and had no idea waht I was doing.
>>
>>108298662
Linux (the kernel) is full of gotos, linked lists, and macros.
>>
>>108297544
15
Countless number of times. When using C, its the proper way to do cleanup of resources on error
>>
>>108297701
based

Reply to Thread #108297544


Supported: JPG, PNG, GIF, WebP, WebM, MP4, MP3 (max 4MB)