|
|
This is NO page from the
dpans'94 document.
It is an experimental draft for public review, here at FORTH.SF.NET |
RFC 2002 |
TOC |
There are usually options to put additional environment library sources under the environment library path prefix so they can be used later.
Some systems may also chose to detect usage of environment queries ending with the four chars "-EXT". The query string gets surrounded by the environment path prefix and a possibly a file suffix, and execute otherwise like REQUIRED.
Environment source files may register additional environment hints by creating words in the ENVIRONMENT-WORDLIST.
: ENVIRONMENT?
ENVIRONMENT-WORDLIST SEARCH-WORDLIST
IF EXECUTE TRUE
ELSE FALSE
THEN
;
and including the REQUIRED-EXT option could follow a scheme not unlike
: ENVIRONMENT?
2DUP
ENVIRONMENT-WORDLIST SEARCH-WORDLIST
IF 2DROP EXECUTE TRUE EXIT THEN
DUP 4 < IF 2R> 4DROP EXIT THEN
2DUP 4- /STRING S" -EXT" COMPARE IF 2DROP EXIT THEN
2DUP 2>R REQUIRED 2R>
ENVIRONMENT-WORDLIST SEARCH-WORDLIST
IF EXECUTE TRUE EXIT THEN
FALSE
;
GET-CURRENT ENVIRONMENT-WORDLIST SET-CURRENT
MAXCOUNTED CONSTANT /COUNTED-STRING
0x50 CONSTANT /HOLD
MAXSTRING CONSTANT /PAD
8 CONSTANT ADDRESS-UNIT-BITS
TRUE CONSTANT CORE
TRUE CONSTANT CORE-EXT
-10 7 / -2 = CONSTANT FLOORED
0xFFFFFFFF CONSTANT MAX-CHAR
0x7FFFFFFF.FFFFFFFF 2CONSTANT MAX-D
0x7FFFFFFF CONSTANT MAX-N
0xFFFFFFFF CONSTANT MAX-U
0xFFFFFFFF.FFFFFFFF 2CONSTANT MAX-UD
0x100 CONSTANT RETURN-STACK-CELLS
0x100 CONSTANT STACK-CELLS
TRUE CONSTANT DOUBLE
TRUE CONSTANT DOUBLE-EXT
TRUE CONSTANT EXCEPTION
TRUE CONSTANT EXCEPTION-EXT
TRUE CONSTANT FACILITY
FALSE CONSTANT FACILITY-EXT
FALSE CONSTANT MEMORY-ALLOC
FALSE CONSTANT MEMORY-ALLOC-EXT
TRUE CONSTANT FILE
TRUE CONSTANT FILE-EXT
TRUE CONSTANT TOOLS
TRUE CONSTANT TOOLS-EXT
TRUE CONSTANT SEARCH-ORDER
TRUE CONSTANT SEARCH-ORDER-EXT
#VOCS CONSTANT WORDLISTS
TRUE CONSTANT STRING
TRUE CONSTANT STRING-EXT
#-LOCALS CONSTANT #LOCALS
( previous ) SET-CURRENT
S" /HOLD" ENVIRONMENT?" ( -- false | size true )A word calling ENVIRONMENT? is supposed to use an IF statement that consumes the true/false flag, and in the true case to handle the additional values returned through execution of the symbol found in the ENVIRONMENT-WORDLIST. When an implementation of this wordsets implements the extension of the ENVIRONEMENT word, the following two code fragmant are almost identical.
: .HOLD S" /HOLD" ENVIRONMENT? IF . ELSE ." unknown" THEN ; \ and S" /HOLD" ENVIRONMENT? [IF] DROP : .HOLD [ ALSO ENVIRONMENT ] /HOLD [ PREVIOUS ] . ; [ELSE] : .HOLD ." unknown" ; [THEN]The difference is that the latter is faster while the earlier will allow later compiling to add a definition of /HOLD to the ENVIRONMENT-WORDLIST to be found during execution of the word.
Table of Contents
Next Section