4 ms·
goto to a line number is not the very nice... adding a new line will mess up all the previous gotos
by google234123 7y ago
goto to a line number is not the very nice... adding a new line will mess up all the previous gotos
- seisvelas 7y agoYou're getting downvotes from the people who don't know that you are 100% right: goto is usually with labels, not line number, for exactly the reason you point out. This Gist is still super cool, though.
- pjc50 7y agoFurther back, BASIC lets you go to a line number .. but the line numbers are explicit and not required to be consecutive. In fact you'd routinely leave holes in the numbering in order to insert an extra line without breaking it. Better systems offered a "renumber" function. Others .. didn't.
- seisvelas 7y ago>BASIC lets you go to a line number QBasic let you use either a line number or a label, I believe they only kept line numbers after labels were introduced for backwards compatibility. I know I'm veering way off topic but for as much disdain as BASICs receive, I really do feel like coding up a simple game was much easier for teenage-me in QBasic than it was in Python with pygame, for whatever reason.
- pjc50 7y agoI think a lot of people have reported having that experience, and I think it's been deeply under-investigated by programming language researchers.
- jbay808 7y agoMy first programming experience was QBASIC. Even if it's not a good programming pattern, I think GOTO is a great way to let a novice programmer "discover" the idea of loops and functions for themselves. Although it's error prone, it's still very intuitive for someone with no programming background.
- sitkack 6y agoQBasic is actually a really awesome language, I am bummed I didn't embrace it like I should have. I ended up going C/C++ ... Perl ... Python. I wasted a lot of time with C/C++, if I had immersed myself in QBasic, I would have better actualized myself.
- xashor 7y agoLABEL = sys._getframe().f_lineno print(1) j(LABEL)
- CivBase 7y agoPast labels are easy, but what about future labels? print(1) goto('MYLABEL') print(2) label('MYLABEL') print(3) Or better yet... for x in range(10): for y in range(10): if x == 5 and y == 5: print(x, y) goto('MULTIBREAK') label('MULTIBREAK')