🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #244

Re: [OF] ... worth it?

#244
From: albert
Date: Sun, 22 Nov 2026 12:22
54 lines
2833 bytes
In article <6af9083e$1@news.ausics.net>, dxf  <dxforth@gmail.com> 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

I favour CONDS ... THENS introduced by Anton Ertl.
Perfectly understandable and very flexible.

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.
Technical Details
Message-ID: <nnd$2d1a7d21$530b25b5@3b90a28b4a9e0eb2>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abo001.abavia.com!feed.abavia.com!abr003.abavia.com!abp004.abavia.com!reseller!not-for-mail
References: <6af9083e$1@news.ausics.net>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.forth
Subject: Re: [OF] ... worth it?
References: <6af9083e$1@news.ausics.net>
From: albert@spenarnc.xs4all.nl
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$2d1a7d21$530b25b5@3b90a28b4a9e0eb2>
Organization: www.abavia.com
Date: Sun, 22 Nov 2026 13:22:34 +0100
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abo001.abavia.com!feed.abavia.com!abr003.abavia.com!abp004.abavia.com!reseller!not-for-mail
Lines: 55
Injection-Date: Sun, 22 Nov 2026 13:22:34 +0100
Injection-Info: reseller; mail-complaints-to="abuse@abavia.com"
X-Received-Bytes: 2642