goto spaghetti1 goto spaghetti8 goto spaghetti6 goto end1 goto start5
OK, first of all, I am not a programmer. (yes, I heard the "thank god") Perhaps I could make the top example simpler.
But anyway, I kind of like goto too much. I find it more intuitive to just jump around and re-use parts rather than think about how to do loops without too much nesting.
In high school, we only did Python. I really wanted to do goto in Python as well, but all I found was this April fools' goto module.
Now in college we're starting with C, and I am starting with Bad Habits^TM^.
Anyway, tagging every line was BASICally just for the joke, but it is useful to just jump to any random line.
103
Comments25
You should try assembly. Pure goto hell
It's always fun to get your offset slightly wrong, and jump into the middle of an instruction.
Oh but only on fully built arm cores which support both thumb and the other mode!
That way all you instructions the debugger shows will be wrong as well since you will have swapped asm mode. (This should, however, fix some off by one jumps because the core should adjust the address. The nice change will continue wracking havoc so not much is lost...)
That is until you're doing something more complex, then goto becomes no-go.
Except for error handling, perhaps
Not even that. Switching code flows means potential void of state integrity. Error handling should either terminate discarded states or not interfere at all.
By the way, imagine smart pointers with goto jumps.
That reminds me of this video
This video is so fucking funny lol. I can't tell whether it's ironic or not
Aww hell no, still getting nightmares on classic asp error handling.
Might I introduce you to functions?
Need to write a prompt to the console and get an input? That could be a function. Need to check if a character matches some option(s)? That's could be a function. Need to run a specific conditional subroutine? That could be a function. And function names, done correctly, are their own documentation too.
You main function loop could look almost like pseudo code if you do it right.
I love the BASIC style labels on each line!
Got a bit too much into BASIC?
I'm glad you included the April Fool's Day link. Comefrom is the worst thing I've ever seen.
— Edsger W. Dijkstra, Communications of the ACM. 11, 3 (March 1968). 147–148.
Gotos are cool, it’s the way assembly works, if your mind likes them then more power to you. But if you work on teams then it’s a nogoto. Most of the functionality can be replaced with things that most people find easier. Just enjoy your time with and don’t ever is Kotlin. Fucking let me fucking return. I see them now those snooty opinionated safety fanatics “ooooh it will be so elegant in the closures the last value will be the return” bs.
This is the one thing that I really dislike about Rust. All this talk about safety and the return value/expression reads like a typeo w/o a semicolon. It even has
returnanyway since there are lots of scenarios that's needed for an optimal path.Content not viewable in your region.
Yeah, catbox was broken, and I don't know another embeddable image host.
Lemmy.
Functions to the rescue!
What's with the line numbers counting down?
I think they're relative line numbers (a setting in vim). So they count down to where the cursor is currently at. (and would count upward form there)
Yep.
Nice, what do you need them for though? Relative movements?
I haven't yet mastered Vim, but say I want to delete a block of text, then I immediately see the relative line number up to which I want to delete lines + 1 (because current line is basically zero).
Say I have:
And I want do delete d,e and f, I do
3dd. With more lines, I don't have to count.