(C) 2000 - 2001 Guido Draheim
@see LGPL for licensedescription:
this wordset implements a simple module-system.
the basic module-system is based on the three
words MODULE/END-MODULE/EXPORT - these three were
present TEK' mforth, here the MPE' forth is used
as an example for the naming scheme. This
implementation has also mpe's EXPOSE-MODULE,
and it has a serious form of mpe's REQUIRES
under the name ALSO-MODULE which clarifies that
the search-order is modified. Note also that
pfe defines a REQUIRES in require-ext that works
( "name" -- old-current )(
create a new WORDLIST with the given name. It
will also have an implicit hidden vocabulary just as
well and all DEFINITIONS will go into that
hidden wordlist. Therefore the old CURRENT is
memorized on the cs-stack.
effectivly, CONTEXT will have the wordlist-id
of the public wordlist "name" and CONTEXT will
have the hidden wordlist contained in "name" - the
hidden wordlist will always be known as HIDDEN' so
that it can be re-referenced without need to use
ALSO just to access a single definition from
just another vocabulary. Note that HIDDEN' is
defined immediate (a VOCABULARY' ) to modify
the ORDER inside a colon definition.
CURRENT @ ( -- old-current )
ALSO LATEST NAME> EXECUTE ALSO DEFINITIONS
C" HIDDEN'" $CREATE WORDLIST CONTEXT !
( old-current -- )(
clean up the cs-stack from the last MODULE
definition. Effectivly, MODULE definitions can
: END-MODULE ( old-current )
PREVIOUS PREVIOUS CURRENT !
( old-current "name" -- old-current )(
the named word in the hidden dictionary (i.e.
the wordlist referenced in CURRENT) is exported
into the public wordlist of it (i.e. which is in
this implementation CONTEXT). The actual
implemenation will create a DEFER-word in the
public wordlist withits parameter area pointing
to the cfa of the hidden implementation.
CURRENT @ CONTEXT CELL+ @ CURRENT !
DEFER CURRENT !
LATEST COUNT CURRENT @ SEARCH-WORDLIST
IF LATEST NAME> >BODY ! ELSE ABORT" can't find word to export" THEN
( "name" -- )(
affects the search order, ALSO module-wid CONTEXT ! hidden'
ALSO S" HIDDEN'"
' DUP VOC? ABORT?" is no vocabulary" >VOC
SEARCH-WORDLIST 0= IF " no hidden vocabulary found" THEN
DUP VOC? ABORT?" hidden is no vocabulary" EXECUTE
( "name" -- )(
affects the search-order, ALSO module-wid CONTEXT !
' DUP VOC? ABORT?" is no vocabulary"