SET-ORDER

( widn ... wid1 n -- )

Set the search order to the word lists identified by widn ... wid1. Subsequently, word list wid1 will be searched first, and word list widn searched last. If n is zero, empty the search order. If n is minus one, set the search order to the implementation-defined minimum search order. The minimum search order shall include the words FORTH-WORDLIST and SET-ORDER. A system shall allow n to be at least eight.

Implementation:

This is the complement of E.16.6.1.1647 GET-ORDER.

: SET-ORDER ( wid1 ... widn n -0 )
   DUP -1 = IF
     DROP <push system default word lists and n>
   THEN
   DUP #order !
   0 ?DO I CELLS context + ! LOOP
;

Testing:

T{ GET-ORDER OVER      -> GET-ORDER wid1 @ }T
T{ GET-ORDER SET-ORDER -> }T
T{ GET-ORDER           -> get-orderlist }T T{ get-orderlist DROP get-orderList 2* SET-ORDER -> }T
T{ GET-ORDER -> get-orderlist DROP get-orderList 2* }T
T{ get-orderlist SET-ORDER GET-ORDER -> get-orderlist }T

: so2a GET-ORDER get-orderlist SET-ORDER ;
: so2 0 SET-ORDER so2a ;

T{ so2 -> 0 }T     \ 0 SET-ORDER leaves an empty search order

: so3 -1 SET-ORDER so2a ;
: so4 ONLY so2a ;

T{ so3 -> so4 }T    \ -1 SET-ORDER is the same as ONLY

ContributeContributions