In case of input, this is, i believe, very undesired 'feature'. Especially, if the expression evaluator in this case can reference variables.
For example:
Code: Select all
>LIST
10 JOHN = 30
20 INPUT A
30 PRINT A
>RUN
?JOHN
30
This renders input almost useless.
Rudla
It's a feature.
Not really. Let's add this line to my original example:
Now all John's are out of luck.
Not really, however I'm not sure you quite understand - but I'll keep banging the drum - this is TinyBasic. Variables are one character only. There is virtually no string handling. It was designed to fit into as small a memory footprint as possible, (c1975) so things have to compromise. At one point, I was desperately trying to save just one byte in the EEPROM - It's just 4KB and at that point in time I had all the serial IO routines as well as the TinyBasic interpreter. I spent weeks "code golfing" to save enough bytes to add new commands into it to control the GPIO pins, and so on. The original would run in under 3KB of RAM on an 8080, leaving just 1KB free for your program. You would happily put up with features like this just to be able to sit back at your own computer and run a BASIC program.
So the side-effect of calling the evaluator on an input string is just that - a side-effect. It would add a few more bytes to the code if I were to call the number parser, then push that into the arithmetic evaluation stack, then pop if off into a variable when there is one routine that can do all that and more. This is code re-use at quite an intense level.
Having an option to evaluate a string is superb feature to have, but EVAL operator would be, in my opinion, much safer option for this than INPUT. And with much wider use...
Of course, i understand, it would cost some bytes, so it may be hard to include.
Rudla
Maybe you need to think about the time when this was written - 1975. We had virtually no memory in the systems then - 4K was a luxury for a home user and compromises were made and understood.
Sure, today with GB of RAM, you might well say why bother, but sometimes it's nice to remember history as it was.
I do have another BASIC interpreter which I wrote from scratch, but it's in C, needs Linux and a good system to run. It solves all these issues, but there is no-way it's ever going to run on a 6502. Not even a 65816 with 16MB of RAM. The alternative today? Well, MS Basic is out there, as is the infinitely superior BBC Basic, also the Paul Robson Basic(s) for the 6502 and '816. go for it.
-Gordon