<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


LITERAL Search:

In Compilation Words in TurboForth Kernal

Word Name: LITERAL
Type: Immediate compiling word
Data Stack Signature: n --
Return Stack Signature: --
Availability: V1.0  V1.1  V1.2
Description:

Compiles LIT n to the current definition. n is a 16-bit cell.

Example:

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.

Comment:

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).

See Also: [  ]  LIT 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>