Proposal: [345] Allow the text interpreter to use `WORD` and the pictured numeric output

Informal

This page is dedicated to discussing this specific proposal

ContributeContributions

ruvavatar of ruv [345] Allow the text interpreter to use `WORD` and the pictured numeric outputProposal2024-06-20 12:04:57

Author

Ruv

Change Log

  • 2024-06-20 Initial revision

Problem

In traditional implementations, the Forth text interpreter itself uses the word WORD and thus it clobbers a transient region containing the parsed lexeme. But the standard does not allow the Forth text interpreter to clobber this region.

Ditto for the words <#, #>, when, for example, the text interpreter shows the stack items after the input string is interpreted.

This problem was pointed out in the contribution [315] WORD and the text interpreter by Anton Ertl.

Solution

The proposed options are:

  1. Fix the systems to avoid clobbering the WORD buffer in the text interpreter
  2. Change the standard to allow clobbering the word buffer by parsing in the text interpreter.

Since the word WORD will be obsolete in any case, there is little point in fixing the systems. Therefore, I propose to change the standard so the text interpreter can overwrite this buffer.

Concerning the pictured numeric output string buffer, it can be used when numbers are displayed, according to 3.2.1.3 Free-field number display: "Number display may use the pictured numeric output string buffer".

An additional benefit is that the user will be allowed to implement their own limited but standard-compliant text interpreter using WORD (this approach is probably used in some old programs) and displaying numbers.

Proposal

Add into the section 3.3.3.6 Other transient regions, after the second paragraph (that ends with "could also corrupt the regions.") the following paragraph:

The data space regions identified by WORD and #> may become invalid after any step in the Forth text interpreter loop.

Reply New Version