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