EXTENSIONS
does the work of POSTPONE on the execution token that
you got from somewhere else - so it checks if the name
(that correspond to the execution-token argument) is
actually immediate, so it has to be executed to compile
something, e.g. IF or THEN - see also POSTPONE ,
COMPILE , [COMPILE] , INTERPRET
|
useful ordinary primitive
takes the execution token of the following word and
saves it on the compile-stack. The correspondig closing
) will then feed it into >COMPILE - so this pair
of word provides you with a prefix-operation syntax
that you may have been seen in lisp-like languages.
($ IF ($ 0= A1 @ )) ($ THEN ." hello " )
Note that an opening simple ( paren is a comment.
|
useful immediate primitive
takes the execution-token from ($ and compiles
it using >COMPILE
|
useful immediate primitive
uses SPRINTF to print to a temporary 256-char buffer
and prints it to stdout afterwards. See the example
at SPRINTF of what it does internally.
|
useful ordinary primitive
just like the standard sprintf() function in C, but
the format is a counted string and accepts %#s to
be the format-symbol for a forth-counted string.
The result is a zeroterminated string at dest$ having
a length being returned. To create a forth-counted
string, you could use:
variable A 256 ALLOT
15 " example" " the %#s value is %i" A 1+ SPRINTF A C!
A COUNT TYPE
|
useful ordinary primitive
EXTENSIONS PRINTF
no special info, see general notes
useful loader code P4_xOLD
EXTENSIONS SPRINTF
no special info, see general notes
useful loader code P4_xOLD
loads a file just like INCLUDE but does also put
a MARKER in the LOADED dictionary that you can
do a FORGET on to kill everything being loaded
from that file.
|
useful ordinary primitive
In PFE it is a synonym to DEFER which a semistandard word.
Unlike DEFER , the DOER -vector was set with an a small
piece of code between MAKE and ;AND . The "DOER"-word
should be replaced with DEFER IS , which is easy since
the DEFER and DOER point to the same internal runtime.
|
useful ordinary primitive
make a seperated piece of code between MAKE and ;AND
and on execution of the MAKE the named word is twisted
to point to this piece of code. The word is usually
a DOER but the current implementation works
on DEFER just as well, just as it does on other words who
expect to find an execution-token in its PFA. You could even
create a colon-word that starts with NOOP and can then make
that colon-word be prefixed with the execution of the code piece.
This MAKE
does even work on LOCALS| and VAR but it is uncertain
what that is good for.
|
useful compiling primitive
For the code piece between MAKE and ;AND , this word
will do just an EXIT . For the code outside of
the MAKE construct a branch-around must be resolved then.
|
useful compiling primitive
executes 0= but this word is immediate so that it does
affect the cs-stack while compiling rather than compiling
anything. This is useful just before words like [IF] to
provide semantics of an [IFNOT] . It is most useful in
conjunction with "[DEFINED] word" as it the sequence
"[DEFINED] word [NOT] [IF] " can simulate "[IFNOTDEF] word "
|
useful immediate primitive
create a new offsetword. The word is created and upon execution
it add the offset, ie. compiling runtime:
( address -- address+offset )
|
useful defining primitive
useful loader code P4_xOLD
will handle the body of the named word as a sequence of cells (or tokens)
and replaces the n'th occurences of from-xt into to-xt. A negative value
will change all occurences. A zero value will not change any.
|
useful ordinary primitive
useful ordinary primitive
look for the filename created by LOADF that had been
defining the given name. LOADF has created a marker
that is above the INCLUDED file and that
marker has a body-value just below the
INCLUDED file. Hence the symbol was defined during
LOADF execution of that file.
: LOADF-LOCATE ?EXEC POSTPONE ' (LOADF-LOCATE) .NAME ;
|
useful ordinary primitive
# ifdef PFE_WITH_FIG
EXTENSIONS #WITH-FIG
no special info, see general notes
useful ordinary constant
# endif
# ifdef WITH_NO_FFA
EXTENSIONS #WITH-NO-FFA
no special info, see general notes
useful ordinary constant
# endif
create a defer word that is initialized with the given x-token.
|
useful ordinary primitive
create a defer word that is initialized with the given x-token.
|
useful ordinary primitive
places a counted string on stack
containing bytes specified by hex-string
- the hex string may contain spaces which will delimit the bytes
example:
X" 41 42 4344" COUNT TYPE ( shows ABCD )
|
useful compiling primitive
check if the name exists, and execute it immediatly
if found. Derived from POSSIBLY as seen in other forth systems.
: [POSSIBLY] (') ?DUP IF EXECUTE THEN ; IMMEDIATE
|
useful immediate primitive
create an immediate vocabulary. Provides for basic
modularization.
: [VOCABULARY] VOCABULARY IMMEDIATE ;
|
useful ordinary primitive
immediatly set topmost CONTEXT voc to CURRENT compilation voc.
: DEF' CURRENT @ CONTEXT ! ; IMMEDIATE
note that in PFE most basic vocabularies are immediate, so that
you can use a sequence of
FORTH ALSO DEFINITIONS
[DEF] : GET-FIND-3 [ANS] ['] FIND [FIG] ['] FIND [DEF] ['] FIND ;
where the first wordlist to be searched via the search order are
[ANS] and [FIG] and FORTH (in this order) and which may or may not
yield different flavours of the FIND routine (i.e. different XTs)
|
useful immediate primitive
EXTENSIONS VOCABULARY'
no special info, see general notes
useful loader code P4_xOLD
EXTENSIONS DEF'
no special info, see general notes
useful loader code P4_iOLD
GET-CONTEXT and count how many times it is in the order but
the CONTEXT variable itself. The returned number is therefore
minus one the occurences in the complete search-order.
usage:
ALSO EXTENSIONS CONTEXT? [IF] PREVIOUS [THEN]
ALSO DEF' DEFAULT-ORDER
: CONTEXT?
0 LVALUE _count
GET-ORDER 1- SWAP LVALUE _context
0 ?DO _context = IF 1 +TO _count THEN LOOP
_count
;
|
useful ordinary primitive
accesses CONTEXT which is generally the last named VOCABULARY .
sets a flag in the vocabulary-definition so that words are matched
case-sensitive.
example:
VOCABULARY MY-VOC MY-VOC CASE-SENSITIVE-VOC
OBSOLETE! use DEFS-ARE-CASE-SENSITIVE
|
useful ordinary primitive
accesses CURRENT which is generally the last wordlist that the
DEFINTIONS shall go in. sets there a flag in the vocabulary-definition
so that words are matched case-sensitive.
example:
VOCABULARY MY-VOC MY-VOC DEFINITIONS DEFS-ARE-CASE-SENSITIVE
|
useful ordinary primitive
binds CONTEXT with CURRENT . If the CURRENT VOCABULARY is in
the search-order (later), then the CONTEXT vocabulary will
be searched also. If the result of this word could lead into
a recursive lookup with FIND it will throw CURRENT_DELETED
and leave the CURRENT VOCABULARY unaltered.
example:
MY-VOC DEFINITIONS MY-VOC-PRIVATE DEFS-ARE-SEARCHED-ALSO
|
useful ordinary primitive
OBSOLETE!! use DEFS-ARE-SEARCHED-ALSO
|
useful loader code P4_xOLD
EXTENSIONS !NO
no special info, see general notes
useful forthword synonym
EXTENSIONS !USE
no special info, see general notes
useful forthword synonym