Kite Programming Language

kite-llvm and eval support

Written by Mooneer Salem on Wednesday 5th of December, 2012 in Usage

Tonight, the eval construct was finally added to kitellvm. This feature has always been in the original Kite but was never added to the LLVM version.

What is eval, you ask? Think of it as a way to dynamically compile and execute code. Example:


harry-2:build mooneer$ bin/kite
eval "\"hello, world!\"|print;";
^D
hello, world!
harry-2:build mooneer$

You can also modify variables defined outside of the eval:


harry-2:kite-llvm mooneer$ cat tests/semantics/eval/modify_variables.kt
i = 0;
eval "i = i + 1;";
i|print;
harry-2:kite-llvm mooneer$ src/kite ./tests/semantics/eval/modify_variables.kt
1
harry-2:kite-llvm mooneer$

This works because eval is effectively equivalent to dynamically compiling a new method whose arguments are the contents of the symbol table at the eval call. :)

Feel free to leave a comment if you have any questions~

Add comment