,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2023-12-24 03:10:07 lmr wrote: | requestClarification - control stack clearing? | see: https://forth-standard.org/standard/core/QUIT#contribution-324 `------------------------------------------ `QUIT` must clear the return stack. But is there any part of the spec that mentions clearing the *control* stack? I don't see any mention of that in `QUIT`, `THROW`, `ABORT` or `:`. ,---------. | Replies | `---------´ ,------------------------------------------ | 2023-12-24 15:50:50 AntonErtl replies: | requestClarification - control stack clearing? | see: https://forth-standard.org/standard/core/QUIT#reply-1148 `------------------------------------------ The control-flow stack may be (and usually is) on the data stack, so the obvious intent is that QUIT preserves it, and that THROW and ABORT restore it to the depth it had at the CATCH that caches the ball. However, the exception wordset chapter mentions the control-flow stack only in the names of exceptions, not as something that THROW should restore. And I don't find any such requirement elsewhere. I think we should fix this in the document. ,------------------------------------------ | 2023-12-24 15:58:11 AntonErtl replies: | requestClarification - control stack clearing? | see: https://forth-standard.org/standard/core/QUIT#reply-1149 `------------------------------------------ BTW, if you are thinking about "system-execution types" like nest-sys and loop-sys, they are specified to be conceptually on the return stack. If you place them elsewhere, they have to follow the changes on the return stack. In particular, they have to be restored on THROW, CATCH and eliminated at QUIT. Recently a bug was found that hit two Forth systems that independently decided to keep the loop-control parameters in registers, and failed to restore them on THROW. ,------------------------------------------ | 2023-12-24 19:16:57 lmr replies: | requestClarification - control stack clearing? | see: https://forth-standard.org/standard/core/QUIT#reply-1150 `------------------------------------------ > that QUIT preserves it, and that THROW and ABORT restore it to the depth it had at the CATCH that caches the ball ... and that (to be pedantic), subsequently, `THROW` and `ABORT` clear the data stack — that *is* specified ,------------------------------------------ | 2023-12-24 22:44:43 lmr replies: | requestClarification - control stack clearing? | see: https://forth-standard.org/standard/core/QUIT#reply-1151 `------------------------------------------ > control-flow stack may be (and usually is) on the data stack Actually I've never quite understood the rules for manipulating the data stack while `STATE` = -1 (via `[` `]` or immediate words). Do not let pushed items cross control-flow primitive boundaries (`IF` `AHEAD` etc)? Is this clearly specified for "standard programs" anywhere?