Hi Bernd,
I believe, mailing list does not accept attachments, so sending to you
directly. With the help of google translate and my friend I have managed
to produced the thing in attachment. It is translation of the parts
about modules (not complete) from update110.tex file. If you can look at
it, correct the meaning if I am wrong and add it to the main
documentation - that'd be great. One thing is, the update is obsolete.
For example findmod has completely different stack notation in the code.
This makes me think that even some semantic might have changed. The
example with floating module does not work:
ANS bigFORTH 386-Linux rev. 2.1.8
m' float savemod float No such file or directory �
Float module is included and it is on the voc stack.
Thanks!
--
Sergey
\chapter{Module - Concept}
\section{A Linker for FORTH?}
\initial Forth's unique strength (at least before Turbo-Pascal was
introduced) is ability to produce working code in a single pass
without engaging a linker. In a FORTH system if the required code
already exists it does not need to be linked.
As with Turbo-Pascal, there are problems for FORTH users who write
very large programs: a hundreds of KBytes source code needs time only
to be consumed by the compiler, even if the compiler is as fast as
FORTH. A common work cycle is changing only small parts of the
programme, compiling, testing, finding a mistake and starting again.
It would be nice, if we could separately compile individual components
of the application as binary code saved and solid, and use them when
they are needed.
An important argument against a linker is now obsolete: using linker
does not necessarily result in a slow down. You can now work in the
main memory. The symbol table is unnecessary in FORTH. The module
must be loaded anyway, or else you can not interpret its words. The
dictionary of the module serves as a replacement of the symbol
table. For the linking itself there is no need in symbols since the
linking is only possible when in the hierarchy descendant modules are
produced by ascendant ones. In this case it is enough to know
addresses to identify the word that must be linked.
The linker in bigFORTH is so fast it can compete with TOS relocator or
with bigFORTH 1.0. Hence the system will be saved momentarily as a
module file and linked only at the time of loading (this is called
load time linking). The loading program itself is less than a
kilobyte.
One example: Download the floating point library; save it as a module;
leave bigFORTH; reboot and then import the binary code from the mass
storage -- depending on its speed, it takes more or less a fraction of
a second.
\begin{flushleft}
\uverb|include float.fs|| \\
\uverb|m' float savemod float|| \\
\verb|saving FLOAT saved ok| \\
\uverb|bye|| \\[1ex]
After restart: \\[1ex]
\uverb|import float| ok| \\
\uverb|float also| ok| \\
\uverb|pi f.| 3.1415926535897932 ok|
\end{flushleft}
\use FORTH.SCR
\voc FORTH
\begin{forth}
\word MROOT {( $--$ addr )} In this variable the pointer to the
root module is stored (it is the kernel module).
\word THISMODULE {( $--$ addr )} User-variable. Points to the module
in which new words are defined.
\word MODULE {( $--$ ) \scan{Name}} Creates a new module with the
name \scan{Name}. Each module receives its own vocabulary. The name
of vocabulary is the module name. The first entry in the vocabulary
is its own name. The search order will be extended, as if ALSO
\scan{Name} DEFINITIONS ALSO are called.
\word MODULE; {( $--$ )} Ends the definition of a module. The module
is shrunk to the minimal size (the space allocated between HERE and
PAD). When the current module is the parent-module, the current
vocabulary (CURRENT and CONTEXT) is its vocabulary. With TOSS TOSS,
the entries of the module are placed in the search order. The
export-routine of the module is called.
\word MAXMODLEN {( $--$ \$8000 )} Constant: The maximum length of a
module (32 ~ KBytes)
\word SAVEDP {( $--$ )} Provides current DP in the corresponding
entry in the module.
\word FINDMOD {( $--$ addr/0 ) \scan{Name}} Finds module
\scan{Name}, and returns its address. If the module is not found,
returns 0.
\word JOINED {( $--$ )} Prefix for MODULE. JOINED MODULE
\scan{Name} creates a module and assigns all words in the CURRENT
vocabulary to it. It is used to allow subsequent expansion of the
module.
\word MODULE[ {( $--$ ) \scan{Name}} Turns on the definition of the
module \scan{Name}. This command and the command MODULES] can switch
between several modules. Modules that can address each other can be
created. It is in effect the command MODULES, but no new module is
created.
\word MODULE] {( $--$ )} Terminates the definition in the current
module. Meets in effect largely MODULE; the module that is being
closed is not reduced, nor will its export-routine called.
\word EXPORT {( $--$ ) \protect\lb\scan{Word} \protect\rb;
immediate} Defines a word list of words to be exported. These
words are defined as aliases at the end of the definition of the
module or by a IMPORT in CONTEXT-vocabulary. They must be visible in
the module! EXPORT can be executed either alone or in a definition
of EXPORT:.
\word COLD: {( $--$ ) \protect\lb\scan{Word} \protect\rb; } Starts
the definition, which will be called with the cold start of the
module (for example at the system startup or at IMPORT from mass
memory).
\word MAIN: {( $--$ ) \protect\lb\scan{Word} \protect\rb; } Starts
the definition with which the module can be started as a
turnkey-application (only during cold boot!). While COLD:-routines
are called in the order, in which the modules were defined, the
MAIN:-routines are called exactly in the reverse order. Because of
that the modules that are defined later can gain the control of the
system at the startup. This definition guarantees that last routine
is the one which clears the screen, issues the initial start message
of bigFORTH and starts the command interpreter.
\word BYE: {( $--$ ) \protect\lb\scan{Word} \protect\rb; } The
following commands will be executed when the FORTH-system will be
exited or saved or the module is removed from the memory. When
leaving the system, the BYE:-routines will be called in the reverse
order compared to the COLD:-routines. Important: if it is needed to
restore the values of reseted words then they can be pushed onto and
out of the return stack using R$>$ and $>$R commands.
\word EXPORT: {( $--$ ) \protect\lb\scan{Word} \protect\rb; : ( addr
$--$ )} The following commands are executed at IMPORT of the
module or when MODULE; is called. When called, the stack will
contain the address of the module. It will be needed, for example,
for the command EXPORTVOC.
\word EXPORTVOC {( addr $--$ )} Exports the vocabulary of the
module. EXPORTVOC will be set by MODULE; as EXPORT:, unless
otherwise defined.
\word (MODULECOLD {( addr $--$ )} This word is needed later for
IMPORT word. Since it must be defined in the kernel in any case, it
remains visible. It calls all COLD:-routines in module {\bf addr}
and all its descendant modules. For the ordinary user, it is not
useful, because after loading it can be applied only if the module
is not yet linked to the next.
\word MODULEBYE {( addr $--$ )} Retrieves all BYE:-routines of the
module {\bf addr} and all its descendant modules. The sequence of
calls is exactly the opposite of (MODULECOLD.
\end{forth}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]