Digest #305 2025-08-07

Contributions

[396] 2025-08-06 10:23:06 EricBlake wrote:

comment - Example in header should feature standard Forth

At the top of https://forth-standard.org/ in the example box is:

\ another shorty, hello world looks like that
." hello world"

And yet, https://forth-standard.org/standard/core/Dotq states "An implementation may define interpretation semantics for ." if desired. In one plausible implementation, interpreting ." would display the delimited message. In another plausible implementation, interpreting ." would compile code to display the message later. In still another plausible implementation, interpreting ." would be treated as an exception. Given this variation a Standard Program may not use ." while interpreting." The example as given only works on implementations like gforth that have defined interpretation semantics to be immediate display. Would it be better to use .( hello world) as the example that has standardized behavior, rather than ."?

Replies

[r1474] 2025-08-05 01:19:19 EricBlake replies:

referenceImplementation - Implementing FM/MOD with SM/REM

RDROP is not part of the standard; your reference implementation should spell it out as R> DROP.


[r1475] 2025-08-05 20:34:58 EricBlake replies:

proposal - find-name

What should be the behavior when find-name is passed a 0-length string? Should it be -16 throw, or should it be a successful return of 0 for not found?


[r1476] 2025-08-06 01:34:04 ruv replies:

proposal - find-name

What should be the behavior when find-name is passed a 0-length string?

Nothing special. The result is either 0 or an nt of a system-dependent word whose name is a zero-length string (depending on the system and the search order).

In some early Forth versions a word with a zero-length name was an immediate word that does refilling of the input buffer. Now the Forth text interpreter does not depend on the presence of such a word.


[r1477] 2025-08-06 01:48:30 ruv replies:

referenceImplementation - Reference implementation should not use -ROT

Or, we could go the route of documenting the use of a buffer,

Note that if you want to avoid memory leaks, you need to store each buffer in the list and correctly free some buffers in catch.


[r1478] 2025-08-06 02:24:08 ruv replies:

requestClarification - May OF modify the enclosing case-sys on the control stack?

I would change the stack diagram for of to ( C: case-sys1 -- case-sys2 of-sys ) — this stack diagram will formally allow the system to throw an exception if case-sys1 is absent on the top of the control-flow stack, and it will require a program to restore case-sys1 if it is temporary removed (and the data stack is used for the control-flow stack items).

A possible option: ( C: case-sys -- case-sys of-sys ), assuming that two occurrences of the same data type symbol without an index in a stack diagram does not mean the same actual value in the corresponding positions of the stack.


[r1479] 2025-08-06 03:21:37 ruv replies:

requestClarification - 3.2.1.1 vs. Double-cell integer behavior on unusual integer architectures

So my idea was to pick some arbitrary cutoff (maybe 2^52) which I declare as my point of overflow,

Note that all data space addresses must fit within this cutoff, since address arithmetic is allowed in Forth programs.


[r1480] 2025-08-06 05:59:34 AntonErtl replies:

requestClarification - May OF modify the enclosing case-sys on the control stack?

An occurence of the same name (wether it contains a number or not) before and after the -- means that the value is the same (e.g., dup, swap). So if we change the stack effect of of, it should be changed to ( case-sys1 -- case-sys2 of-sys ).


[r1481] 2025-08-06 06:49:26 AntonErtl replies:

proposal - find-name

In general, a word should not throw if there is a way to express the outcome through the regular return values. In the present case, if you don't have a zero-length name in the search order, find-name should return 0.


[r1482] 2025-08-06 11:37:45 EricBlake replies:

testcase - Suggested test

Looking deeper, https://github.com/gerryjackson/forth2012-test-suite.git includes a much simpler test for AGAIN:

T{ : AG0 701 BEGIN DUP 7 MOD 0= IF EXIT THEN 1+ AGAIN ; -> }T
T{ AG0 -> 707 }T

added in version 0.12. As that was released in 2015, but the web page still refers to the testsuite as published in 2012, it explains why I didn't find it earlier.