Digest #277 2024-08-13

Contributions

[359] 2024-08-12 13:32:06 ruv wrote:

requestClarification - Behavior of EMPTY-BUFFERS when BLK is nonzero

Should not we add:

An ambiguous condition exists if BLK contains a non-zero when EMPTY-BUFFERS is invoked.

Replies

[r1292] 2024-08-12 07:40:55 ruv replies:

comment - Resolve the forward reference orig1 using the location following the appended run-time semantics.

It talks about then patching the branch added by else

The spec does not use the term "patching". Some Forth systems employ two-pass compilation of a definition (it is allowed), without any patching. If you patch a branch — it's your implementation detail.

Anyway, we can forget about else for a moment. The following shall work without errors:

: bool-to-n ( x -- 1|0 ) if 1 ahead [ 1 cs-roll ] then 0 then ;

t{ false bool-to-n -> 0 }t
t{ true  bool-to-n -> 1 }t

And the Forth system is allowed to compile the above definition to a code that does not contain any branches at all, for example to a code like this:

: bool-to-n ( x -- 1|0 ) [: 1 ;] [: 0 ;] ifelse ;

Where ifelse does not perform any jump/branch, but only an indirect call:

: ifelse ( i*x  x.bool  xt.on-true xt.on-false -- j*x )
  rot 0= tuck and ( xt.on-true flag xt.on-false|0 )
  -rot 0= and ( xt.on-false|0 xt.on-true|0 )
  or execute
;

[r1293] 2024-08-12 20:23:21 ruv replies:

requestClarification - shadowed names

Just for reference. We forgot that the change in wording for traverse-wordlist was accepted in 2020. And it says that the old wording (i.e., that in Forth-2012) already gives guarantee that the shadowed words are visited.