This section documents the words used for defining locals. Note that
the run-times for the words (like W:) that define a local are
performed from the rightmost defined local to the leftmost defined
local, such that the rightmost local gets the top of stack.
Start locals definitions.
During a locals definitions with {: everything from
-- to :} is ignored. This is typically used
when you want to make a locals definition serve double duty as
a stack effect description.
Locals defined behind | are not initialized from the
stack; so the run-time stack effect of the locals definitions
after | is ( -- ).
Ends locals definitions.
Start locals definitions. The Forth-2012 standard name for this
word is {:.
Ends locals definitions. The Forth-2012 standard name for this
word is :}.
Don’t use ‘locals| this read can't you|’! Use {:
you can read this :} instead.! A portable and free {:
implementation can be found in compat/xlocals.fs.
Define local name with the initial value x.
name execution: ( – x1 ) push the current value of name.
to name run-time: ( x2 – ) change the value of
name to x2.
+to name run-time: ( n|u – ) increment the value of
name by n|u.
Define local name, reserve a cell at a-addr, and store x there.
name execution: ( – a-addr ).
Define local name with the initial value x1 x2.
name execution: ( – x3 x4 ) push the current value of name.
to name run-time: ( x5 x6 – ) change the value of
name to x5 x6.
+to name run-time: ( d|ud – ) increment the value of
name by d|ud.
Define local name, reserve two cells at a-addr, and store x1 x2 there.
name execution: ( – a-addr ).
Define local name with the initial value c.
name execution: ( – c1 ) push the current value of name.
to name run-time: ( c2 – ) change the value of
name to c2.
+to name run-time: ( n|u – ) increment the value of
name by n|u.
Define local name, reserve a cell at c-addr, and store c there.
name execution: ( – c-addr ).
Define local name with the initial value r.
name execution: ( – r1 ) push the current value of name.
to name run-time: ( r2 – ) change the value of
name to r2.
+to name run-time: ( r3 – ) increment the value of
name by r3.
Define local name, reserve a float at f-addr, and store r there.
name execution: ( – f-addr ).
Define local name with the initial value r1 r2.
name execution: ( – r3 r4 ) push the current value of name.
to name run-time: ( r5 r6 – ) change the value of
name to r5 r6.
+to name run-time: ( r7 r8 – ) increment the value of
name by r7+r8i.
Define local name, reserve two floats at f-addr,
and store r1 r2 there.
name execution: ( – f-addr ).
Define local name; set name to execute xt1.
name execution: execute the xt that
name has most recently been set to execute.
Is name run-time: ( xt2 – )
set name to execute xt2.
Action-of name run-time: ( – xt3 )
xt3 is the xt that name has most recently been set to execute.
Apart from {: and {, none of these words are normally in
the search order (they are in the vocabulary locals-types); on
other Forth systems, they may not even be words (the standard
documents |, -- and :} under {:, not as
separate word, and the other words are non-standard).