Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: Looking for some help with this gforth program. Thanks! Date: Wed, 11 May 2016 17:08:17 -0700 Organization: A noiseless patient Spider Lines: 13 Message-ID: <87y47g5ea6.fsf@jester.gateway.pace.com> References: <6548d185-2c31-40a4-bfa9-a3c353e9fa5d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="a2ceffa7691480425df36ffcd2162f1d"; logging-data="18872"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vuUEyxkUcUqrnqK9DhQsg" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:3W5Jifq5XQ4INzPvXfzIEJyWhdo= sha1:63Qkapa8Umib4cmFFiHMv7vRfWE= Xref: csiph.com comp.lang.forth:47024 murphy.darin@gmail.com writes: > other times I get garbage and a "stack underflow" error. Wolfgang made good suggestions. Another gforth-specific tip: the word "~~" (two tilde characters) prints the stack contents along with a diagnostic saying where in the program the message came from. That is good for debugging: you put ~~ into places in your program where you want to trace what is going on. At a higher level, I see a lot of duplicated code between those (penny, nickel, etc.) The idea of "factoring" is to put the duplicated stuff into subroutines that are defined just once, which you can then call from multiple places.