programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: Drag List Boxes

From: Rick VanNorman <rvn_at_forth.com>
Date: Tue, 07 Nov 2000 07:40:05 -0800

Thanks, Mike!

On 11/6/2000 at 4:15 PM Mike Ghan wrote:

>> Second, the DUP OF words ENDOF structure is interesting.
>
>A simple technique I use to "clean up" the selector in the case statement
>"default" behavior. This allows altering the stack balance without keeping
>track of the selector. Although the phrase DUP OF TRUE ENDOF could be
>easily written as SWAP TRUE, I prefer the DUP OF ENDOF technique if the stack
>changes get any more complex.

This is my personal preference for ending a case statement too. It makes
much more obvious what is being returned/done in the default case.

>> is doomed to stack over or underflow ( I suspect over).
>
>Right again - almost. It would overflow if this was a traditional FORTH
>program. What makes things tricky in Windows is (jump in and clarify Rick) that
>for every windows message, a stack frame is created and then destroyed after the
>message is processed. Any minor Forth stack problems disappear. When testing,
>one has to verify stack correctness for each message since a stack imbalance is
>not cumulative. For example, try adding
>100 0 DO I LOOP 0 ( res ) to the end of a message. The stack frame mechanism
>seems much less tolerant to underflows, only a couple (Rick?) of words.

This is exactly correct. In a callback, the stack overflow tolerance is
very large, on the order of 2k cells. Underflow is limited to about 4 cells.
On each callback entry, a new, empty stack frame is created; on exit the
entire stack frame is discarded and only the top value on the stack is returned.

Clear as mud?

Rick VanNorman
Received on Tue Nov 07 2000 - 07:51:54 PST

This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:28 PST