Article View: comp.lang.forth
Article #242Re: [OF] ... worth it?
From: Hans Bezemer
Date: Fri, 20 Nov 2026 18:00
Date: Fri, 20 Nov 2026 18:00
59 lines
3173 bytes
3173 bytes
What about : EQU over = ;
1 floats 4 EQU [if] 38 [ELSE]
8 EQU [if] 308 [ELSE]
10 EQU [if] 4932 [ELSE]
drop 1 abort" unknown float size"
[THEN] [THEN] [THEN] constant pmax drop
It's nearly as clean as "Using [OF]".. ;-)
Hans Bezemer
On 15-11-2026 02:17, dxf wrote:
> Existing:
>
> 1 floats dup 4 = [if] 38 [ELSE]
> dup 8 = [if] 308 [ELSE]
> dup 10 = [if] 4932 [ELSE]
> drop 1 abort" unknown float size"
> [THEN] [THEN] [THEN] constant pmax drop
>
> Using [OF]:
>
> 1 floats 4 [of] 38 [ELSE]
> 8 [of] 308 [ELSE]
> 10 [of] 4932 [ELSE]
> drop 1 abort" unknown float size"
> [THEN] [THEN] [THEN] constant pmax
>
> While the latter is cleaner it requires [ELSE] be extended. Here's the
> change using the source given in ANS-Forth A.15.6.2.2533.
>
> : [ELSE] ( -- )
> 1 BEGIN \ level
> BEGIN
> BL WORD COUNT DUP WHILE \ level adr len
> 2DUP S" [IF]" COMPARE 0= >R
> 2DUP S" [OF]" COMPARE 0= R> OR
> IF \ level adr len
> 2DROP 1+ \ level'
> ELSE \ level adr len
> 2DUP S" [ELSE]"
> COMPARE 0= IF \ level adr len
> 2DROP 1- DUP IF 1+ THEN \ level'
> ELSE \ level adr len
> S" [THEN]" COMPARE 0= IF \ level
> 1- \ level'
> THEN
> THEN
> THEN ?DUP 0= IF EXIT THEN \ level'
> REPEAT 2DROP \ level
> REFILL 0= UNTIL \ level
> DROP
> ; IMMEDIATE
>
> : [OF] ( x1 x2 -- | x1 )
> OVER = DUP IF NIP THEN POSTPONE [IF] ; IMMEDIATE
Technical Details
Message-ID:
<11dq1so$3de8o$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<6af9083e$1@news.ausics.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Hans Bezemer <the.beez.speaks@gmail.com> Newsgroups: comp.lang.forth Subject: Re: [OF] ... worth it? Date: Fri, 20 Nov 2026 19:00:56 +0100 Organization: A noiseless patient Spider Lines: 59 Message-ID: <11dq1so$3de8o$1@dont-email.me> References: <6af9083e$1@news.ausics.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 20 Nov 2026 18:00:57 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3586328"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qC044k98Stw5+PvuL0MGI"; posting-host="3dffc44b397646d065d3c3c1f45d53eb" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:z/IUmM/AdKhubrUz5GIYiYrEy5A= sha256:LrvuvM+v7QEjBM/4xmRaZivDWcHoI21N/NuVnNKSwq0= sha1:WZ4tNFaKRIls0BTKOI4E9yNXJpY= sha256:2LQmWK7/rTbUj9VzZ+xw+kRJJIaqLgcJnn+JuQ2jOdM= Content-Language: en-US In-Reply-To: <6af9083e$1@news.ausics.net>