16.6.2.1965 ONLY SEARCH EXT

( -- )

Set the search order to the implementation-defined minimum search order. The minimum search order shall include the words FORTH-WORDLIST and SET-ORDER.

Implementation:

: ONLY ( -- ) -1 SET-ORDER ;

Testing:

T{ ONLY FORTH GET-ORDER -> get-orderlist }T

: so1 SET-ORDER ; \ In case it is unavailable in the forth wordlist

T{ ONLY FORTH-WORDLIST 1 SET-ORDER get-orderlist so1 -> }T
T{ GET-ORDER -> get-orderlist }T

ContributeContributions

JimPetersonavatar of JimPeterson [377] First Tests Seem WrongSuggested Testcase2025-04-23 19:58:40

The definition says "The minimum search order shall include the words FORTH-WORDLIST and SET-ORDER.", but the first test uses the words FORTH and GET-ORDER after calling ONLY. An otherwise conforming implementation could fail this test, and honestly it would be better if FORTH was also required in "the minimum search order", as I imagine many are used to using "ONLY FORTH" in their code.

ruvavatar of ruv

It's a known problem. For example, see the comp.lang.forth discussion "Is there a hole in the SEARCH wordset?" from 2008 (and many other). Since then, no one has prepared a proposal on this matter.

but the first test uses the words FORTH and GET-ORDER after calling ONLY. An otherwise conforming implementation could fail this test,

Yes. Also, ONLY and FORTH words can be absent at all (because they are in the Search-Order extension word set), and then an otherwise conforming implementation will fail this test too.

it would be better if FORTH was also required in "the minimum search order"

It cannot be unconditionally required because FORTH belongs to the Search-Order extension word set. But it can say: "If the word FORTH is provided, the minimum search order shall include this word".

This is consistent with practice: typically, if the words ONLY and FORTH are both provided, the phrase ONLY FORTH works as expected.


The term "minimum search order" can be confusing. A better option: "minimum operational search order" (see a discussion in comp.lang.forth).

Reply New Version