Date : Fri, 07 Dec 2012 18:06:57 +0000
From : famrowland@... (Andrew Rowland)
Subject: Granny's Garden
Kris,
BBC Basic in the Beeb had FNs but not multi-line IF, regrettably. Also,
all variables were global by default, which encouraged the poor style
you describe. Unless you explicitly defined variables in a function/sub
as LOCAL, they applied everywhere, so half your debugging time was spent
tracking down accidental spelling mistakes, which led to a new variable
being created when your intention was to assign a value to an existing
one, and accidental re-use of a variable name in another location
leading to unwanted interactions. Those were the days! I guess the
reason behind that design decision was, apart from the general culture
in BASIC at the time, performance. The more LOCAL variables, the greater
the overhead of procedure and function calls.
I can remember being puzzled like you by the bad style used by many
'professional' programmers of the time. I put it down to their writing
for many different platforms or having learnt on something else and
bringing old habits to the Beeb. Most BASICs of the time were not as
structured as BBC Basic.
Your description of the stack problems from all those GOTOs reminds me
of my earliest effort, where I wanted to use the Escape key to flip
between two screens in my program. By default, Escape generates and
error, which resets all the REPEAT and PROC stacks. I ended up having it
GOTO into the middle of loops and putting in an extra error handler to
catch the resulting mess up when it hit the end of a loop or PROC it
didn't know it was in the middle of. That was before I discovered you
could change the action of Escape to produce an ASCII code instead! I
think 50% of program was a massive spaghetti-style error handler.
Andrew
On 07/12/2012 10:41, Kris Adcock wrote:
> Morning gents!
>
> I meant to pass this link around t'other week, but I've been dying of
> man-flu:
>
> http://www.danceswithferrets.org/meeblog/?p=1757
>
> I imagine all you guys have already completed Granny's Garden, but for
> me it was quite important to finish off something that I started in
> primary school. :)
>
> On a related note: on writing the above, I looked through the BASIC
> listing for GG to see if there was any rhyme or reason to many of the
> puzzles (it turns out there isn't, but there was still some interesting
> reading).
>
> I was quite shocked to discover that the code is really quite dreadful!
> There is an unhealthy mix of GOTOs and PROCs, no use of FNs when they
> would have been a much more elegant solution, and a fair few dirty
> tricks to clean-up the stack (which leaks like buggery thanks to all the
> PROCs-and-GOTOs).
>
> But I was just wondering: were FNs and multi-line IFs only added to
> later versions of BASIC? This might explain some of the programmer's
> choices ... or was it just that he didn't know about them?
>
> So far I'm resisting the urge to rewrite it all. I think after thirty
> years, that ship has sailed. :)
>
> All the best,
>
> Kris Adcock
>
> _______________________________________________
> bbc-micro mailing list
> bbc-micro@...
> http://lists.cloud9.co.uk/mailman/listinfo/bbc-micro
>