Compile - Geomol/World GitHub Wiki

Usage

compile source /at context /reset

Description

Compiles a function or block to executable code.

compile is a function!

Arguments

source -- [function! block!]

Refinements

/at -- Choose a context for compilation
  context -- Reference to the target context [context! word! block!]
/reset -- Reset the compile state

Related

Compiled?, Disasm

Examples

w> c: [a: 2 b: 20 a + b]
== [a: 2 b: 20 a + b]
w> disasm c
** Script error: block hasn't been compiled yet
** Near: disasm c
w> compile c
== [a: 2 b: 20 a + b]
w> disasm c
   0 LOADK            0                2
   1 SET_TVALUE       90ee53808db2588  0                
   2 LOADK            0                20
   3 SET_TVALUE       2108dab958       0                
   4 GET_TVALUE       0                8db2588          
   5 GET_TVALUE       1                24908dab958      
   6 ADD              0                0                1               
   7 END              0                                 

Note that compile does not actually evaluate the expressions, but creates the World Virtual Machine instructions.