Wednesday 15 April 2020

FORTH yet not FORTH

Have a working RPL compiler as a unary function, but not a dictionary yet. Just a few test words. It's very , but not exactly like FORTH. The main obvious difference is in the variables - these are prefixed with ^ and & ; so &count is the same as count @ and ^count is the same as count ! in FORTH. This is because it has to work with the BASIC variable system.

You also have a static read-only dictionary - word addresses are stored in BASIC variables (hence the ^ and & operators !), and can't (at the moment anyway) define immediate words. The structures will be simplified. But it is recognisably the same.

One thing which is actually a plus point is it can't split a definition over two lines of code (you can have a very long screen line). This has the benefit that it almost forces you to break up definitions into smaller ones rather than writing whole page definitions, which I kinda think you should be doing anyway.

There is a comma, because the syntax parser and lister is designed to deal with BASIC and the comma compiles nothing but can be used to clarify the syntax e.g. do you want +! or + ! ; by writing +,! it becomes simpler. It is an issue because the spacing is done entirely by the lister, no spaces are stored in the tokenised code. It's not like Microsoft BASIC, if you look at it as characters it's largely unreadable.

No comments:

Post a Comment

Breaking change

We all make mistakes. One early mistake I made was copying (partly) the old thing in Microsoft BASIC where you didn't have to declare ...