home .. forth .. misc mail list archive ..

RE: questions (about x21)


Dear MISC readers:

Greg wrote:

>On Mon, 5 Jun 2000, Don Golding wrote:
>
>> I agree wholheartedly that 18 stack levels are more than sufficient for
good
>> Forth programming.  I have been programming in Forth for over 10 years
and I
>
>I think you're forgetting calls.  One word may never have more than 4 items
on
>the stack, but what about the word that called it?  I think I can usually
keep
>it to less than 6, but I'll have to be constantly paying attention "I'm
using
>3 levels on the stack, and this word I'm calling, it's only using 2,
right?"
>Whereas with 18 levels, I would not even have to think about that very
often.
>There may be a preference for code that uses few levels of nesting, but
that
>is not my immediate preference.

Don was talking F21 and Greg is talking P21 and they are very different in
that the return stack is very shallow on P21 and the programmer must manage
both data and return stack spill and fill (or the compiler must manage it.)
In Chuck's examples you can see where he does this and can read his comments
that he is doing it when he has talked about his code.  One should not think
that OKAD only requires a total of 4 return stack cells ever.  Phil Koopman
shows some interesting numbers for the percentage of code that must deal
with stack spill and fill as related to the size of the on-chip stack.  It
reflects what I have seen.  The number drops from a few percent to next to
nothing as the number of on chip stack items gets up near 16.  So it is
a few percent (at most) of the code on P21.  

I think the having to pay attention because of the restricted architecture
is why Michael said that P21 was more fun to program than F21.  You have to
think a little on P21.  But I think Chuck and Michael and I all think that
programming with thinking is better than programming without thinking.  Of
course you don't want to have to think about too many details at one time.
There is a rule about how many details people can keep in their heads
at once and with the exception of some savants or people who play chess
with a room full of people at once the number is pretty small.  Keeping
track of what you are doing with the data and return stacks is one of things
you get to think about in Forth.

Jeff Fox