From Newsgroup: comp.lang.forth
In article <87ecejfbum.fsf@localhost>, David Meyer <
papa@sdf.org> wrote:
The Gforth manual documents a "wordset" for each word. Many of these
wordsets are defined in the ANS Forth standard. However, these wordsets
do not appear in the list of system vocabularies and wordlists displayed
by VOCS. I think the standard wordsets are included in the vocabulary >"Forth".
Is there any way to access individual wordsets from within the Gforth >environment? I'd like to set up the search order to allow the use of
only a subset of standard words.
There is a general way to do this, that works on any Forth.
Define a wordlist and call this RESTRICTED (whether you use VOCABULARY
or NAMESPACE to define a named wordlist)
Define FROM and IMPORT appropriately.
Then specify
RESTRICTED DEFINITIONS
FROM FORTH IMPORT DROP 2DROP ROT SWAP 2SWAP
..
ad nauseam.
..
\ An non-portable implementation on ciforth:
\ Intended to be used "FROM: wordlist IMPORT <name1> <name2> "
\ Announce wordlist, temporarily added to search order
: FROM: ; \ For NAMESPACE
\ : FROM: ALSO ; \ For VOCABULARY
\ Import remainder of the line to CURRENT, then remove "FROM:"d context.
: IMPORT ^J PARSE SAVE SET-SRC
BEGIN GET-NAME DUP WHILE FOUND ALIAS REPEAT 2DROP \ 1]
RESTORE PREVIOUS ;
Then start your program with
ONLY RESTRICTED
1] SET-SRC (string-constant - ) set the input temporarily to the string.
Gforth supplies EXECUTE-PARSING that provides a similar function,
only more cumbersome.
I used a similar mechanism to define a mini-forth with 64 words, plus
3 debug words (show stack, clear stack, words) and 4 for
extending(include import from: want)
--
David Meyer
Groetjes Albert
--
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.
--- Synchronet 3.22a-Linux NewsLink 1.2