I have used goto instruction a lot when I started to program in Basic ( an Amstrad CPC 🥹). In this context goto had logic. But in modern languages like python I think it is a very bad idea:
Understand the logic is more complex
Functions and methods are a better and more powerfull alternative
It is dangerous: add or remove a new line of code could have bad consequences
11 Comments
xurxia@mander.xyz · 8 pts · 3y
Hi,
I have used goto instruction a lot when I started to program in Basic ( an Amstrad CPC 🥹). In this context goto had logic. But in modern languages like python I think it is a very bad idea:
Regards
stOneskull@programming.dev · 1 pts · 3y
i've found a good alternative is returning functions
eg. you have a function like this:
def cycle(func): while True: func=func()then you start with cycle(main)
def main(): return introif __name__ == '__main__: cycle(main)and then main returns the next function, and following functions return functions..
def intro(): if thisthing: return thisfunc if thatthing: return thatfuncreturn is being used like goto
shayan16sa@techhub.social · 2 pts · 3y
@stOneskull @xurxia man it's really cool
stOneskull@programming.dev · 2 pts · 3y
you can see how i use it here: godschat
read from the bottom up
Yearly1845@reddthat.com · 3 pts · 3y
RangerHere@programming.dev · 1 pts · 3y