+\ Sets the twelfth local variable's value +: Local11! ( x - )
- 11 CELL * getBaseAddress + !
+;
...why stop at 11?
As far as I know, Apple's code only uses two local variables at most. I figured 12 local variables per word should be enough.
Apple's code uses a maximum of eight locals (and they actually use (close to) that -- really badly factored code).
Neither 8 nor 12 is anywhere near close enough to allow compiled C code to run. Any implementation that limits the number of allowed locals is only good for letting people who are not yet comfortable with programming Forth code get something done. Whether it is better to let them do that, or force them to learn to use Forth properly first, is not something I want to get into here ;-)
[SNIP a word of 30 lines, indented to hell and back, impossible to read]
Factor this? You shouldn't ever use a variable that is used as a temp inside a word.
I'm not sure why you suggest this. It is just such a pain having to deal with the stack.
That's why you should factor it! A normal word should deal with maybe two or three data items only, and do only one thing. The main problem is coming up with good names for your words (thankfully you do not have to do this for data items, because you do not use locals); but then again, if it is hard to think of a good name for a word, it probably does more than one thing. So factor some more :-)
alloc-mem is way too slow to be used on every function call. Statically allocate a locals stack, or put it on an existing stack, or something like that.
I agree. That is why it is only used at compile time.
That wasn't clear to me. Maybe you should put in some more comments? A good thing to comment are your data structures and the global data, often the words using that are clear then as well.
Segher