[
and switch back into compile mode with ]
.
The following example defines the word feet
that converts a number
representing a length in feet to an equivalent number of millimetres.
The intermediate result is in tenths of a millimetre so that precision is retained and,
to make the conversion clear, the numeric conversion factor is computed
as we compile the word.
: feet ( u1 -- u2) [ #254 #12 * ] literal #10 u*/mod swap drop ; ok<#,ram> 10 feet ok<#,ram>3048The word
literal
is used to compile the data value in TOS
into the definition of feet
.
At run-time, that data value will be placed onto the stack.