![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

Stack checking is performed at the user interface, not internally (unless
you build it in yourself).
In other words, if you type commands during testing, the stack will be
checked for underflow between the commands you type, but not internally
within those commands. The reason is simple: overhead. To check the
stack in DUP, for example, would roughly double its cost, 100% overhead.
Detecting stack problems is pretty easy if you follow the recommended
debugging procedure of testing your application words individually,
bottom-up (lowest-level words first). Always make sure the stack effect
corresponds to the stack comment in the source file! Never write a great
long application and start by testing its highest-level command, that's a
recipe for hours of frustration.
The occurrance of that particular number is probably a consequence of
whatever's happening in your program prior to the underflow (in otherwords,
it could have happened a while before the DUP).
Cheers,
Elizabeth
At 05:04 PM 4/11/02 -0700, Gene Silvernail wrote:
>Something as simple as DUP bit me. I've always assumed that DUP checks the
>stack and would error if the stack was empty, not so.
>
>Don't have the exact number but....
>
>When DUP is run on an empty stack I get the number 658, I believe, in
>return. Not 2 numbers, ie the original and a copy but just the one
>658. No indication that that the stack was empty.
>
>Late one night I actually provided 2 errors in a word that countered each
>other. The 1st was the use of DUP with an empty stack and the 2nd placed
>a number on the stack that made up for the empty DUP stack.
>
>How or where does one look or find which words perform a test on the stack??
>
>Gene SIlvernail
>
>
>----------------------------------------------------------------------
>swiftx_at_forth.com The SwiftX programming discussion email list
>To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
>For help with listar commands, send subject "help" to listar_at_forth.com
>Archives are located at http://www.forth.com/swiftx -- check them out!
>----------------------------------------------------------------------
>THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
Received on Thu Apr 11 2002 - 17:29:20 PDT
This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:23 PST