Proposal: [291] Obsolescence for SAVE-INPUT and RESTORE-INPUT
This page is dedicated to discussing this specific proposal
ContributeContributions
ruv
[291] Obsolescence for SAVE-INPUT and RESTORE-INPUTProposal2023-03-02 19:04:49
Author
Ruv
Change Log
- 2023-03-02 Initial version
Problem
The words SAVE-INPUT
and RESTORE-INPUT
almost don't bear any usefulness to programs, and they only burden implementers.
These words have the following problems:
- Too few guarantees to programs:
RESTORE-INPUT
may work or fail depending on on the input source kind (file, pipe, string, keyboard). - The returned flag of
RESTORE-INPUT
is inconsistent with other words: true means fail, false means success. A better variant could be a throwable ior. - In some systems
RESTORE-INPUT
works incorrectly in some cases: it restores the position in the input buffer and returns success, but doesn't restore the content of the input buffer.
These words are almost not used in programs. I asked in comp.lang.forth and ForthHub. Only one program was mentioned: "Lambda Expressions in ANS Forth" by Gerry Jackson (sources), and in this case the problem can be also solved without these words.
What is sometimes required in programs is an ability to parse (extract) a text fragment from the input stream, and later translate (evaluate) this fragment in the current context, regardless whether the input stream was switched or not. Such an API should be designed separately. The words SAVE-INPUT
and RESTORE-INPUT
cannot help on that.
Solution
Declare the words SAVE-INPUT
and RESTORE-INPUT
as obsolescent, to destandardize (remove from the standard) them on the next iteration.
Consequences
This change doesn't affect the standard systems. The new (or updated) standard systems can be made slightly simpler by not providing an implementation and documentation for these words (if they are not used internally).
The standard programs that employ these words gain a new environmental dependency, and later they become non compliant to the new versions of the standard.
Proposal
In the section 1.4.2 Obsolescent features, after the phrase "This standard designates the following word as obsolescent:", add:
- 6.2.2182 SAVE-INPUT
- 6.2.2148 RESTORE-INPUT
In each of the glossary entries 6.2.2182 SAVE-INPUT
and 6.2.2148 RESTORE-INPUT
add the following note:
Note:
This word is obsolescent and is included as a concession to existing implementations.