In Gforth you can postpone a local (or use a local inside
]]...[[, see Macros). Given the normal lifetime of
locals (see How long do locals live?), what does this mean?
Consider:
: foo {: W: n D: d F: r C: c XT: xt -- :} POSTPONE n POSTPONE d POSTPONE r POSTPONE c POSTPONE xt 0 ->n #0. ->d 0e ->r 0 ->c `abort =>xt ; immediate
This is equivalent to
: foo {: W: n D: d F: r C: c XT: xt -- :} n POSTPONE literal d POSTPONE 2literal r POSTPONE fliteral c POSTPONE literal ACTION-OF xt compile, 0 ->n #0. ->d 0e -> r 0 ->c `abort =>xt ; immediate
I.e., when applied to locals, postpone compiles the value that
the local has at the point of the postpone, not any later value
of the local. This solves the problem that the local does not live
indefinitely, and it also results in efficient code. But in general
it does not produce the value that an infinite-lifetime local would
have at the place where the local is compiled into by the
postpone (what a Scheme programmer would expect). However, as
long as you do not use TO, +TO, IS or ADDR
on the same local as POSTPONE, the latter produces the result
that a Scheme programmer would expect.
Concerning using locals without TO and friends, see Locals programming style.
Using postpone with variable-flavoured locals produces an error
during compilation.