| Deutsch English Français Italiano |
|
<vrmm9l$994t$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: sjack@dontemail.me (sjack)
Newsgroups: comp.lang.forth
Subject: Re: Back & Forth - Co-routines
Date: Sat, 22 Mar 2025 15:51:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <vrmm9l$994t$1@dont-email.me>
References: <nnd$2fb29a8e$298ef3f8@23fe4f00fa62d734> <49736c0ec0e34ca5d67f4e0d6e8cbe2a080e38ab@i2pn2.org> <vnkvvq$2a5o$1@dont-email.me> <nnd$14fbaf4d$1e462a10@60e007c2d8488e4d> <vnq10p$162l3$1@dont-email.me>
Injection-Date: Sat, 22 Mar 2025 16:51:18 +0100 (CET)
Injection-Info: dont-email.me; posting-host="577a4f05d2c7eef3ac889e0648a0727b";
logging-data="304285"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fC0HDOP6jury6TAsw/upb"
User-Agent: tin/2.6.4-20240224 ("Banff") (Linux/6.8.0-55-generic (x86_64))
Cancel-Lock: sha1:AB/aADEsyEF0sdyWel0kMJ8SB4w=
Bytes: 2267
Ruvim <ruvim.pinka@gmail.com> wrote:
> An artificial example:
While wondering down roads less taken, I took a path where
bacForth CUT: and -CUT were used in lieu of CATCH THROW .
( ENTER is the same as ';:' )
: LOCAL ( x adr -- )
r> -rot dup @ over 2>r ! ENTER 2r> ! ;
\ prefixed '-' to indicate this word does a cut
: -idiv ( n1 n2\0 -- n3 | n1 0 -- true )
dup if /
else 2drop true -CUT
then
;
: ?idiv ( n1 n2 -- n1/n2 false | <nothing> )
CUT: -idiv ." Valid: " false
;
42 variable a
42 variable b
: ?/ ( u1 u2 -- u1/u2 )
a local b local
b @ a @ ?idiv
if ." Bogus! " 666 then .
;
i. 100 5 ?/ --> Valid: 20
i. a ? b ? --> 42 42
i. 100 0 ?/ --> Bogus! 666
i. a ? b ? --> 42 42
forget ?/
: ?/ ( u1 u2 -- u1/u2 )
a local b local
b @ a @ ' ?idiv ENTER
if ." Bogus! " 666 then .
;
i. 100 5 ?/ --> Valid: 20
i. a ? b ? --> 42 42
i. 100 0 ?/ --> Bogus! 666
i. a ? b ? --> 42 42
forget ?/
: ?/ ( u1 u2 -- u1/u2 )
a local b local
b @ a @ (: cut: -idiv ." Valid: " false ;) ENTER
if ." Bogus! " 666 then .
;
i. 100 5 ?/ --> Valid: 20
i. a ? b ? --> 42 42
i. 100 0 ?/ --> Bogus! 666
i. a ? b ? --> 42 42
+echo
-fin-