Linked by Thom Holwerda on Wed 27th Mar 2013 10:45 UTC
General Development "Programming is hard. Don't ever feel bad because you aren't as good at 'just googling it' as the person next to you. Don't ever let hackathon snobs talk you out of creating the next Twitter for cats or Yelp for public washrooms. Even the dumbest ideas (like trying to make animated polygons disappear and reappear) will help you improve as a programmer. Learning to program is largely about learning to learn - and the best way to learn is to do." For some reason, I love this short story.
Permalink for comment 556832
To read all comments associated with this story, please click here.
How I invented GoSub
by joshv on Wed 27th Mar 2013 13:41 UTC
Member since:

On my 12th Christmas I was given a TI99/4A. My parents barely knew what it was, or what it did, but I was geek'd. Luckily they didn't have any money to buy games, otherwise I might have spent all my time playing rather than coding and ended up in an entirely different career.

The 99/4A had TI-Basic, a rather competent implementation (for the time), which had a GOSUB. I of course had no idea what the documentation was talking about. GOTO made sense, but GOSUB?

I went about coding with my GOTOs and IFs and quickly found that there were portions of my code that were doing the same thing. Wouldn't it be nice if I could only write that code once instead of having the same lines of code all over the place?

So I put the code in one place at a particular line number, set up some variables for it to work on, and then issues a GOTO to that line number. But then I had another problem, how the heck did I get back to where I came from?

Being a clever lad, I also set a flag before I issued my GOTO, the flag indicated the calling block of code. Then at the end of the block of re-usable code, I interrogated the flag using some IF statements, and issued the GOTO required to return to that calling block.

I rolled my own very fragile subroutines. When I later figured out GOSUB I kicked myself, long and hard.

Reply Score: 12