Re: Neolithic Tiny Basic
Posted: Fri Mar 28, 2025 6:11 am
I've been thinking about READ, DATA, and USR (and incidentally, @(peek)).
As pointed out earlier, there is no function capability in NTB. The only case where this occurs is with @, and that's bolted on in a messy way to factor().
The difference between a statement and a function is that the first takes one or more parameters, executes, and returns the address of the next line to execute. That allows both linear execution and recursion, which is used when control statements are nested. A function takes one or more parameters and returns a value... it seems to me that that a function is only useful as part of an assignation statement:
and that without the assignation, even if the function doesn't return a value (as USR might not) it would be a syntax error. By providing the address of the usr target, the user doesn't have to mess around with poking values into memory before the call. The single parameter would be provided in Y:A and because the user has full access to the core software further parameters can be accessed in any desired style by using the existing parsing mechanism.
DATA is easy; it's a statement that does the same as a comment: nothing.
READ with a line number should return the first data item from that line; without a line number it should return successive data items.
Proposed changes, then:
but you would have to
but I don't see that as too much of a headache.
Neil
As pointed out earlier, there is no function capability in NTB. The only case where this occurs is with @, and that's bolted on in a messy way to factor().
The difference between a statement and a function is that the first takes one or more parameters, executes, and returns the address of the next line to execute. That allows both linear execution and recursion, which is used when control statements are nested. A function takes one or more parameters and returns a value... it seems to me that that a function is only useful as part of an assignation statement:
Code: Select all
1000 a = usr 57554, 55DATA is easy; it's a statement that does the same as a comment: nothing.
READ with a line number should return the first data item from that line; without a line number it should return successive data items.
Proposed changes, then:
- define the DATA statement
- add a new 'is' function: is_a_function() which will return true if the character tested is a function token, or @ (which is a function, but saves memory by not needing a table/enum entry).
- change assignment() to test for and expect a function return value which it can save before moving to the next line.
Code: Select all
100 print read 1000Code: Select all
100 a = read 1000
110 print aNeil