Python Forum

Full Version: set marker goto marker??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Has it ever been considered for python to allow for a goto command??
instead of line numbers, one could place named or numbered markers, and then the interpreter could goto those markers (just like BASIC can go to line numbers)

it's up to the individual to make sure that variables work, or other problems are dealt with.
if the user goes into a function at a point AFTER a variable is cleared or etc. then whatever is already in memory is used, an error if variable is declared before the marker and that line hasn't run yet, etc.

Python is here to be powerful, and enabling. sure, you can just keep making more functions, but as an interpreted language, why not allow for more diversity in flow?? first of all, there are plenty of users who could immediately expand on pythons style using their old childhood methods, games might get fun, and sometimes it would be MUCH LESS TYPING to just say goto and then point, click, and drop a marker
From Python documentation, Design and history FAQ, Why is there no goto?
I see.
it's a more advanced fuctionality, and wouldn't work for any of the times I wanted to use it.
I'm a super-newb.

anyway, from MY perspective,,, I'm perfectly aware that it doesn't cost any capability, but on the other hand, it IS a capability to allow your mind to think any of the ways it does, and it is also a capability to be in the middle of an exercise or project and be able to want, and therefore be able, without changing anything, be able to skip around.

I don't see how it can hurt to have it. also, consider micro-python, and then also the continuous advancement of processing power,, why not just put it in?? if it would be used, make it available, . ????

(I realize YOU aren't responsible, I just mean, for conversation and rebuttal)
Goto statements generate spaghetti code. Spaghetti code is difficult to read, difficult to understand, difficult to maintain, and difficult to troubleshoot. Even in modern languages that incorporate a goto statement, it is avoided like a plague.

Really, any time that you would use a goto, you could just call a function.
Quote:it's a more advanced functionality
Not so! I have been programming now for 50 years.
When I started back in 1968, the concept of subroutine was just beginning, where you would call the function.

As stated by stullis, goto's make for Spaghetti code.
Even in assembly language, calls are preferred over goto, except in rare instances.

I can say for a fact that I haven't used a single goto for over 38 years!
I have to add to what Larz says. I have been working on a collection of text games, which includes several games written in the early days of home computing, using the early versions of BASIC. BASIC just had gotos, and trying to understand what was going on in the code by following the gotos all over the place was incredibly hard. It made me really glad we don't use those any more.