Perhaps I should elaborate. My Forth's
FORGET starts like this:
Code:
: FORGET ( -- )
NAME CURRENT @ DUP CONTEXT !
(FIND) 0= ?FIND >LINK
VOCABULARY is written such that vocabularies are not chained to their parent vocabulary but they do have the address of their parent in their second cell. This is to keep
FORGET from finding <name> if it is not defined in the current vocabulary. The high level word
FIND takes care of following the chains, but it might be a bit slow:
Code:
: FIND ( ADR -- ADR2 FLAG )
CONTEXT
BEGIN
@ ?DUP
WHILE
TUCK (FIND) ?DUP
IF ROT DROP EXIT THEN
SWAP 2+
REPEAT
CURRENT @ (FIND) ;
If the standard permits
FORGET finding <name> in the current vocabulary
or one of its parent vocabularies, I would like to rewrite
VOCABULARY so that vocabularies are more like the the fig Forth model. I could then change
FIND to:
Code:
: FIND ( ADR -- ADR2 FLAG )
CONTEXT @ (FIND)
?DUP 0= 0EXIT
CURRENT @ (FIND) ;
By the way,
0EXIT is a code word that exits if the top of the stack is false
0EXIT ( FLAG -- )
This is why I would appreciate some clarification on the Forth-83 standard's meaning concerning
FORGET.
[EDIT:] Problem solved with a little creative rewriting of the find primitive and adding a new primitive
VFIND which only finds a name in a given vocabulary.
VFIND has no parameter field. Its code field points one byte into
(FIND)'s parameter field.