From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Thu Apr 2 15:27:59 2026
From Newsgroup: comp.lang.forth
Look at this definition of QUIT. '(ACCEPT) is an execution token
that combines the functionality of REFILL and leaves a SRC like
specification like (c-addr n), 1+ adds the line delimiter.
SAVE and RESTORE of the current stream is hidden in INTERPRET :
EPIPE signals the end of the stream
: QUIT
POSTPONE [
BEGIN R0 @ RSP! '(ACCEPT) CATCH DUP EPIPE = IF BYE THEN
THROW 1+ SET-SRC INTERPRET OK AGAIN
;
With slight modification we can define `` break ''
This is a interpreter, but doesn't destroy the return stack .
It is good for interactive debugging.
S[ ] OK SEE break
: break
BEGIN '(ACCEPT) CATCH DUP EPIPE <> WHILE THROW SET-SRC INTERPRET
REPEAT DROP
;
------ testbr.frt -----------------
: doit 1 2 3 .S ;
--------------
after compilation to testbr
testbr
S[ 1 2 3 ]
Now imagine that this is an extremely hard to debug function:
You can insert a break anywhere.
------ testbr.frt -----------------
: doit 1 2 break 3 .S ;
--------------
E.g. you discover that the 2 has to be enhanced to 3:
You type test1 and then 1+ ^D
/tmp: is the directory.
------------------------
/tmp: test1
1+
\ TYPE a control-D to signal end of input.
S[ 1 3 3 ]/tmp:
------------------------
This suggests that break is a useful factor of QUIT,
further simplifying.
(Although I think my QUIT is not particularly involved.)
But somehow I fail to make it fit.
Groetjes Albert
--
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.
--- Synchronet 3.21f-Linux NewsLink 1.2