home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / a293_1 / !AForth_Docs_Semantics_Search < prev    next >
Encoding:
Text File  |  1999-04-27  |  3.0 KB  |  54 lines

  1.  
  2. Semantics for the Search Order and Search Order Extensions Word Sets
  3.  
  4.  
  5. The Search Order word set provides creation and maintainance of word lists and the order in which they are searched. A Forth word list is identified by an identifier, wid.
  6.  
  7. Forth uses an internal array of word list identifiers called the search order. Forth finds a word by searching each word list specified in the search order. A search completes successfully by the first match.
  8.  
  9. The maximum number of word lists in the search order is per default eight, though this can be changed by the Forth command line argument -Wordlists (see the documentation file 'AForth' for details on command line arguments).
  10.  
  11. AForth actually also keeps an internal array of word list identifiers of all word lists created by WORDLIST. This array is shared with the search order, such that for each new defined word list, there is room for one less word list in the search order. The argument given to -Wordlist is automatically multiplied by two, such that there is always room for as many word lists in the search order as the user have defined.
  12.  
  13.  
  14. WORDLIST  Search
  15. ( -- wid )
  16. Create a new empty wordlist and return its identifier wid. The identifier is normally stored in a CONSTANT or a VARIABLE for later use --- the identifier is the only link to words defined in the wordlist.
  17.  
  18.  
  19. SEARCH-WORDLIST  Search
  20. ( c-addr u wid -- 0 ) if not found
  21. ( c-addr u wid -- w 1 ) if immediate found
  22. ( c-addr u wid -- w -1 ) if non-immediate found
  23. Search for the Forth word represented by c-addr u in the wordlist identified by wid. If the word is not found, zero is returned. Otherwise return its execution token w and 1 if the word is immediate, -1 otherwise.
  24.  
  25.  
  26. SET-ORDER  Search
  27. ( wid1 ... widn n -- )
  28. Set the search order to the word lists identified by wid1 ... widn. The word list identified by widn is the first word list to be searched and wid1 the last to be searched. n specify the number of word list identifiers on the stack. If n is zero, the search order is emptied. If n is -1 the search order is set to the implementation defined minimum, which is the search order Forth starts with.
  29.  
  30.  
  31. GET-ORDER  Search
  32. ( -- wid1 ... widn n )
  33. Return the number of word lists n in the search order and the word list identifiers wid1 ... widn identifying these lists. widn represents the word list that is searched first and wid1 the word list that is searched last.
  34.  
  35.  
  36. SET-CURRENT  Search
  37. ( wid -- )
  38. Specify that subsequent definitions will be be placed in the word list identified by wid.
  39.  
  40.  
  41. GET-CURRENT  Search
  42. ( -- wid )
  43. Return the wordlist identifier for the current compilation wordlist. The compilation word list is set by either SET-CURRENT or DEFINITIONS.
  44.  
  45.  
  46. FORTH-WORDLIST  Search
  47. ( -- wid )
  48. Return the wordlist identifier for the Forth word list.
  49.  
  50.  
  51. DEFINITIONS  Search
  52. ( -- )
  53. Specify that subsequent definitions will be be placed in the current first word list of the search order. Subsequent changes in the search order will not affect the word list to which new definitions are added.
  54.