"Zbiggy" <
zbigniew2...@gmail.REMOVE.com> wrote in message
news:slrnjq5628.8f8.z...@Tichy.myhome.org...
> In "Starting Forth" (chapter 11) there is a statement:
>
> #v+
> Be sure to note the "intelligence" built into POSTPONE. POSTPONE
> parses the next word in the input stream, decides if it is immediate or
> not, and proceeds accordingly. If the word was not immediate, POSTPONE
> compiles the address of the word into a compilee definition; think of it
> as deferred compilation. If the word is immediate, POSTPONE compiles the
> address of this word into the definition currently being defined; this
> is ordinary compilation, but of an immediate word which otherwise would
> have been executed.
> #v-
>
> Functionality of POSTPONE in case of "immediate words" is obvious: it
> makes them "non-immediate for this time". But I don't understand the
> second case mentioned - therefore I made an experiment using Gforth:
> [snip]
Are you familiar with COMPILE and [COMPILE] ?
COMPILE and [COMPILE] were defined for fig-Forth, Forth-79, Forth-83.
POSTPONE acts as COMPILE for non-immediate words and [COMPILE]
for immediate words.
Do you have the word SEE or the ability to dump a definition? I.e., can you
SEE or see what is compiled in each case?
If so, in one case, you should see the word compiled into a definition. In
the other case, you should see the word compiled into the definition
preceded by a COMPILE or POSTPONE typically. If it's just the word compiled
into a definition, it'll execute when that definition executes. If COMPILE
or POSTPONE is also present, then the word won't execute but will be
compiled into a new definition.
A basic definition for POSTPONE has been reposted here a few times recently.
They usually look like the following:
(all from old c.l.f. posts)
: POSTPONE BL WORD FIND DUP 0= IF <not found code> THEN 0<
IF COMPILE COMPILE THEN , ; IMMEDIATE
: POSTPONE ( "name" -- ) BL WORD FIND DUP 0= ABORT" -?" -1 =
IF COMPILE COMPILE THEN COMPILE, ; IMMEDIATE
: POSTPONE BL WORD FIND DUP 0= ABORT" ?" 0<
IF COMPILE COMPILE THEN , ; IMMEDIATE
Sometimes they are *far* more complicated. And, other times they have been
converted to use COMPILE, instead of , (comma) or even POSTPONE in terms of
POSTPONE POSTPONE i.e., the initial POSTPONE acts like COMPILE etc.
E.g., some typical posts:
http://groups.google.com/group/comp.lang.forth/msg/a58db7a9be07bd01
http://groups.google.com/group/comp.lang.forth/msg/50cb7b5ae28cf655
HTH,
Rod Pemberton