Today I wrote a program. In BASIC. It had an infinite loop. By accident.
I think that the last time I wrote a BASIC program with an infinite loop (accidental or otherwise) was in the 1980s. (Probably the early 1980s.)
The program was a "Celcius to Fahrenheit" table generator. It was easy enough to write (I do remember BASIC) and it revealed some defects in the BASIC-1965 interpreter. One was in the parsing of arithmetic expressions and the other was in the computation of arithmetic expressions. The parsing was easily fixed, once identified. (I had the wrong logic for precedence of operators.) The calculation of an expression was a bit trickier; Ruby (the language that runs the BASIC interpreter) uses two types for numbers: Float and Integer. My math worked for the add, subtract, and multiple operations; I had to adjust the divide operation to return either a Float or an Integer.
After resolving the problems, my BASIC program works as expected. Woot! Today counts as the day that my first "real" program ran successfully.
Tuesday, April 3, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment