On 06/01/2015 10:30 AM, Peter Heitzer wrote:
> Hello folks,
> for some old Z80 SBC I managed to adopt camel forth 1.2 for standalone
> use. Unfortunately camel forth has not FORGET in its dictionary.
> I'd like to implement it for I find it useful in the develop phase
> but I have not enought knowledge to do it by myself. If anyone already
> has a definition for FORGET I would highly appreciate if he could
> post it.
> Thanks a lot in advance.
>
>
FORGET needs to find the newest definition to keep then set
the dictionary search pointer and the pointer to the end of
used memory.
: FORGET [COMPILE] ' ( LOOKUP NAME FROM INPUT STREAM )
DUP NFA DP ! ( DP IS USED BY HERE, THIS FREES UP MEMORY )
LFA @ CURRENT @ ! ; ( LINK TO PRIOR WORD, SET CURRENT )
( VOCABULARY TO START SEARCH THERE )
This is what I used on a Z80 long ago. Today it is politically
incorrect because it depends on knowing what is in the dictionary
and then touching that. NFA takes what tick gives and adjusts to
the name field address. LFA takes what tick gives and adjusts to
the link field address. DP is end of dictionary pointer.
Warning, don't forget stuff that will cause a problem. If you
create another vocabulary and delete some of its words then the
unforgotten vocabulary head points to deleted stuff that will
soon be written over. If you forget an entire vocabulary that
may be OK. If you have a vectoring word that has been pointed
to forgotten code it will soon fail. Failures will happen at
some time in the future, far from the cause, generating
confusion.