On Sun, Jul 21, 2019 at 09:15:25PM +0200, BALATON Zoltan wrote:
On Sun, 21 Jul 2019, Programmingkid wrote:
I know Forth is big on using the stack as a place for storing variables, but could you use local variables instead? They are so much easier to follow and use than stack manipulation.
No I can't. I don't know how to do that in Forth and most of this is copy pasted from SLOF so you probably don't have to review those parts, only my changes. The string manipulation words are just copy from SLOF and I assume they would work. (Besides Segher said local variables are not a good practice in Forth.)
That's not what I said (I said it is not good *here*), but heh.
You should not deal with many data items at once at all, and then you do not need to name them, and juggling them is only trivial.
Don't name temporary, local data; name routines, instead. Have many very short routines. Routines that do not do much are not normally hard to name, either.
If you have long definitions you have much bigger problems... Such things are hard to test, and even harder to debug.
In Forth, you test everything as soon as you write it (interactive testing is a thing, too!), normally.
If you use Forth the same as you use C, many thing will be frustrating.
Segher