The section 3.3.3.5 Input buffers says:
The address and length returned by SOURCE
, the string returned by PARSE
, and directly computed input-buffer addresses are valid only until the text interpreter does I/O to refill the input buffer or the input source is changed.
(emphasis mine)
On the other hand, LOAD
restores the prior input source specification. Consequently, while the input buffer is being interpreted by LOAD
, the input source remains the same for every word encountered by the Forth text interpreter in that input buffer, no matter how many blocks are loaded by nested LOAD
calls. And while REFILL
(or RESTORE-INPUT
) has not been executed, the directly computed input-buffer addresses shall be valid, contiguous, and their contents shall be the same for every encountered word in that input buffer.
This requirement can be violate in the following conditions (depending on particular implementations):
A block buffer was assigned to a block using BUFFER
, then the block buffer was filled by some contents (without marking this block buffer as UPDATE
ed, intentionally), then LOAD
was called for that block. Since a block buffer was already assigned to that block, LOAD
will not read the block from mass storage device and just interprets this block buffer (see the request for clarification #180). Then, if this block buffer will be assigned to another block in a nested LOAD
, the contents of this input buffer might not be restored.
If a block buffer that is the input buffer will be unassigned using EMPTY-BUFFERS
(maybe even in a nested LOAD
), the block being interpreted might be assigned a different block buffer, and the input-buffer addresses that was computed before that can become invalid, their contents can be modified, or further computed input-buffer addresses will not be contiguous with the previous ones (even if the previous ones are still valid and their contents are unchanged).
All of these edge cases are handled correctly if a block buffer being interpreted is locked from unassigning until its interpretation is complete.
Perhaps this approach could be promoted as a new requirement for systems (see my post in ForthHub). Nowadays, memory limitations are not so restrictive.