Article View: comp.lang.forth
Article #243Re: [OF] ... worth it?
From: dxf
Date: Fri, 20 Nov 2026 23:02
Date: Fri, 20 Nov 2026 23:02
39 lines
2128 bytes
2128 bytes
On 21/11/2026 5:00 am, Hans Bezemer wrote:
> 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]".. ;-)
> ...
The DROP has to be handled manually which complicates. Chances are
folks have used EQU for other things (I have) and perhaps enough reason
to bite the bullet and implement [OF].
I overcame my reluctance to mess with [ELSE] by shifting the tool out
of the kernel and into the user-modifiable TOOLS library. I was worried
about a potential chicken-egg issue but thankfully it worked out.
FWIW here's my def for [ELSE] which is somewhat shorter (for me) than
the ANS version. Exploits TRUE = -1.
: [ELSE] ( -- )
1 begin token 2dup upper dup if
2dup s" [IF]" compare >r 2dup s" [OF]" compare r> and if
2dup s" [ELSE]" compare if
s" [THEN]" compare 0=
else 2drop dup 1 = then
else 2drop 1 then +
else 2drop refill and then ?dup 0= until ; immediate
aka noop [THEN] immediate
: [IF] ( flag -- ) 0= if postpone [ELSE] then ; immediate
: [OF] ( x1 x2 -- | x1 )
over = dup if nip then postpone [IF] ; immediate
Technical Details
Message-ID:
<6b00d19c$1@news.ausics.net>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.bbs.nz!news.ausics.net!not-for-mailReferences:
<6af9083e$1@news.ausics.net> <11dq1so$3de8o$1@dont-email.me>Show Full Headers
Complete Article Headers
Date: Sat, 21 Nov 2026 10:02:52 +1100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [OF] ... worth it? Newsgroups: comp.lang.forth References: <6af9083e$1@news.ausics.net> <11dq1so$3de8o$1@dont-email.me> Content-Language: en-GB From: dxf <dxforth@gmail.com> In-Reply-To: <11dq1so$3de8o$1@dont-email.me> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: news.ausics.net Message-ID: <6b00d19c$1@news.ausics.net> Organization: Ausics - https://newsgroups.ausics.net Lines: 39 X-Complaints: abuse@ausics.net Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.bbs.nz!news.ausics.net!not-for-mail