Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #134854

break

Newsgroups comp.lang.forth
From albert@spenarnc.xs4all.nl
Subject break
Message-ID <nnd$09cbb653$5a02face@a67fcc1862cef500> (permalink)
Organization KPN B.V.
Date 2026-04-02 15:27 +0200

Show all headers | View raw


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.

Back to comp.lang.forth | Previous | Next | Find similar


Thread

break albert@spenarnc.xs4all.nl - 2026-04-02 15:27 +0200

csiph-web