<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>
In Compilation Words in TurboForth Kernal
Compiles LIT n to the current definition. n is a 16-bit cell.
If A B and C are constants, then:
: GET-RESULT A B + C * ;
can be more efficiently expressed as:
: GET-RESULT [ A B + C * ] LITERAL ;
In the first example, (A+B)*C is repeatedly calculated each time GET-RESULT is called. In the second example, (A+B)*C is evaluated in immediate mode (facilitated by [ and ]) and encoded into the colon definition as a literal by means of LITERAL.
[
]
LITERAL
Normally used in conjuction with [ and ] to encode the result of a calculation into a colon definition as a literal (to save having to evaluate the calculation at run-time).