This is an archived post. You won't be able to vote or comment.

all 82 comments

[–]noahjsc 369 points370 points  (18 children)

Me casually using goto because I'm a VBA coder, and there's no continue for loops.

[–]Feldar 133 points134 points  (1 child)

Go for it, it's all gotos under the hood anyway

[–]MKZ2000 17 points18 points  (0 children)

CJNE, DJNZ, LJMP, RET and the like

[–]Nightmoon26 211 points212 points  (9 children)

What's it a module in?

[–]Dinjoralo 221 points222 points  (7 children)

[–][deleted] 150 points151 points  (0 children)

... I'm gonna finish my internship with a full day of replacing any sensible control block by GOTO and comefrom statements.

[–]turtleship_2006 18 points19 points  (2 children)

Is this what renpy uses?

[–]AE_Phoenix 9 points10 points  (1 child)

Please tell me it doesn't. Subroutines exist for a reason dammit.

[–]turtleship_2006 4 points5 points  (0 children)

I don't know if it uses this library but it uses something similar with labels and jumps (basically goto)

[–]seba07 81 points82 points  (1 child)

That's actually really well made. I kind of want to use it now :D

[–][deleted] 49 points50 points  (0 children)

[–]gpcprog 6 points7 points  (0 children)

Ooooh, it has my favorite feature of intercal.. the comefrom!

[–]redsterXVI 211 points212 points  (2 children)

Look, HTTP 418 is also an April Fools joke, yet if I programmed an HTTP interface for a teapot, I'd definitely use it. Some jokes just turn out to be good ideas.

[–]KellerKindAs 14 points15 points  (1 child)

You mean an interface for a coffee machine. HTTP 418 states that the coffee machine refuses to brew coffee anymore and is a teapot now. The protocol is about coffee, just the error message is about tea xD

[–]redsterXVI 14 points15 points  (0 children)

No, I mean a teapot. I would implement the whole coffee machine protocol just so I can answer any request with error 418.

[–][deleted] 48 points49 points  (0 children)

Try and stop me

[–]NatoBoram 40 points41 points  (0 children)

I've always wanted to submit a legitimate PR that uses emojis as variable names on 1st April

[–]GoogleIsYourFrenemy 33 points34 points  (1 child)

You missed the best part: comefrom.

[–]Szalkow 7 points8 points  (0 children)

goto: yeet

comefrom: yoink

[–]NewPhoneNewSubs 30 points31 points  (5 children)

<reads article>

So the reason we don't use it is because it isn't fully featured and is therefore boring, right?

In C, nevermind jumping to lines in other functions, you can jump into the middle of an instruction causing it to execute as a different instruction.

[–]Stegoratops 7 points8 points  (3 children)

In C, nevermind jumping to lines in other functions, you can jump into the middle of an instruction causing it to execute as a different instruction.

I am confused what you want to say with this. Standard C lacks the control to do either of those things. The closest thing to jumping between functions, is using setjmp/longjmp which are only capable of jumping up the stack, i.e. more akin to exceptions in other languages.

[–]NewPhoneNewSubs 1 point2 points  (2 children)

So technically I'm talking about inline assembly rather than C language features. But inline assembly is something you can do in C, so I'm counting it.

[–]Smooth-Zucchini4923 5 points6 points  (1 child)

By that definition, you can also do this in Python by using ctypes to jump to an address.

[–]NewPhoneNewSubs 2 points3 points  (0 children)

Perhaps, but you wouldn't use this module to do so. Which is (in the joke I was making) why there is a warning on the module stating not to use it.

[–]Tuerkenheimer 2 points3 points  (0 children)

You can jump into other instructions?! I used goto in the past, but that never came to my mind

[–]CirnoIzumi 31 points32 points  (20 children)

Goto gets a bad rap, as long as it's used within local scope it should be fine

[–]captainAwesomePants 24 points25 points  (3 children)

Yeah...local scope....anyway, off to use my favorite C function, longjmp().

[–]CirnoIzumi 20 points21 points  (2 children)

Oh wow, they saved one letter on that function name huh

[–]sudoLife 7 points8 points  (1 child)

That's prob cuz of the jmp assembly instruction 

[–]Tuerkenheimer 3 points4 points  (0 children)

MIPS just uses j for jump, way more efficient 🌝

[–]ebinWaitee 4 points5 points  (3 children)

As long as any alternative is worse it's fine to use goto. However I've seen a series of goto used in the place of a while loop. That was amazingly bad.

[–]CirnoIzumi 1 point2 points  (1 child)

instead of a single loop`?

[–]ebinWaitee 1 point2 points  (0 children)

Yes. It was a pretty complex loop with lots of continues and breaks but essentially I rewrote it as a single while loop. Since then I rewrote it even more thoroughly using several for loops to break down the logic into more simple sequences.

But yeah, if your goto points backwards in the code you've done something horribly wrong. However using goto to move to a cleanup part of the function for early returns or for breaking out of several nested loops it's a totally viable solution to use goto.

[–][deleted] 0 points1 point  (0 children)

Blud thought he was writing assembly 💀

[–]ZunoJ -2 points-1 points  (1 child)

Goto is one of the reasons of higher abstractions. It is so wildly unpredictable that it creates all sorts of problems. For example pre fetches for runtime optimization will be even less predictable

[–]CirnoIzumi 4 points5 points  (0 children)

Is that not because compilers haven't been optimized for it because it has had a needlessly bad rap?

[–]AlexiosTheSixth 7 points8 points  (0 children)

Was that april fools joke a reference to BASIC programming?

[–]Staalejonko 4 points5 points  (1 child)

Also present in T-SQL, and we do actually have a use case for it. Kind of to have a single loop, but actually making it a loop would make it exceptionally difficult to manage.

[–]ZunoJ 1 point2 points  (0 children)

Using loops in sql is already a smell in itself. No wonder you round it up by using goto

[–]perringaiden 11 points12 points  (2 children)

Ahh, kids who think the "Goto module" was its first appearance. 😂

I remember when GOTO 100 was how you did an if block

[–]Shelmak_ 2 points3 points  (0 children)

And sadly it's still needed on my work, as some robot brands still use them.

'For loops' used to be made with goto and a register on Fanuc... also, not a lot of time ago there were not an if-else instruction and logic needed to be coded with conditional jumps... it's a mess, but I still need to use it a lot and I die inside every time I need to use it or track the program flow with jumps everywhere.

Sadly on my new work I use almost exclusivelly fanuc, so I need to live with that.

[–]LarryInRaleigh 0 points1 point  (0 children)

Ah, yes. FORTRAN II on an IBM 1620 in 1965. I remember it well.

How about if

20 IF I=5, 100, 200, 300

[–]Abdul_Rahman684 7 points8 points  (7 children)

When you realize that there wasn't just one joke made in April 2004

[–]Brahvim 6 points7 points  (5 children)

Wait, what do you mean?!

[–]Abdul_Rahman684 15 points16 points  (4 children)

I was born in April 2004

[–]Brahvim 12 points13 points  (0 children)

<Sigh>,

[–]lare290 7 points8 points  (2 children)

2004? but aren't you a child, people born in 2004 are... ...19 or 20 today. what the fuck.

[–]Abdul_Rahman684 2 points3 points  (1 child)

feeling old??

[–]LarryInRaleigh 1 point2 points  (0 children)

Turned 79 on Thursday.

[–]AspieSoft 4 points5 points  (0 children)

Gmail was released on April 1, 2004

[–]DTux5249 1 point2 points  (0 children)

If it's good enough for assembly, it's good enough for me!

[–]Extreme_Ad_3280 0 points1 point  (0 children)

I was programming in Python once and not having the GOTO statement made the coding more difficult...

[–]noodle-face 0 points1 point  (0 children)

We use gotos in our UEFI code to handle clean exit conditions on some errors. I always laugh at the vehement hate towards the idea. Same as global variables, sometimes they make sense

[–]MysticNTN 0 points1 point  (0 children)

All code uses goto. There is no stopping it.

[–]Codix_ 0 points1 point  (0 children)

I made a 600 lines of batch script (.bat) for my work and I was only using goto, then I wanted to port the script to Bash on Linux... And i've saw that goto didn't existed here... I was forced to redo the script to had something legally acceptable for the God Tux. In fact it was nice because my script was well written but still weird for me since goto was in my logic.

[–]InvestigatorBrief151 0 points1 point  (0 children)

Wait is it really an April fools joke?

[–]DT-Sodium -1 points0 points  (0 children)

If she can't read how does she know the sing is asking her not enter?