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 kite–llvm. 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~
On a tangent
Written by Mooneer Salem on Thursday 29th of December, 2011 in Usage
harry:kite-llvm mooneer$ ./kite class X [ method z() [ true; ]; method y() [ (make System.exceptions.NotImplemented())|throw; ]; ]; v = make X(); v|y; ^D System.exceptions.NotImplemented: Exception thrown in method X|y + 0xcc in (main program) + 0xfd harry:kite-llvm mooneer$
Notice anything different? Hint: the exception trace looks a lot nicer. :)
Something fun to try
Written by Mooneer Salem on Wednesday 4th of August, 2010 in Usage
Today, I found out about a pretty nifty regular expression that will match if a number is not prime. Turns out that the regex is usable unmodified in Kite:
#!/usr/bin/kite method is_prime(number) [ property rgx; property digit_str; rgx = r/^1?$|^(11+?)\1+$/; digit_str = ""; until(number == 0) [ digit_str = digit_str + "1"; number = number - 1; ]; (rgx|match(digit_str) is System.null); ]; (is_prime(17))|print; (is_prime(3))|print; (is_prime(20))|print;
Results:
true true false
Unfortunately, because of the way the regular expression engine in Kite works, it took much longer than 14 seconds to run the check for the large numbers tried in the article. This will be another facet of the overall Kite optimization effort in the future as well. :)
1.0.3 released
Written by Mooneer Salem on Monday 13th of April, 2009 in Usage
Kite 1.0.3 has been released.
New in this release:
- Fixed problems with the Windows installer.
- Fixed bugs in kdb.
Download:
- Source: http://www.kite-language.org/files/kite-1.0.3.tar.gz
- Debian packages: http://www.kite-language.org/files/binaries/deb/1.0.3/
- Windows installer: http://www.kite-language.org/files/kite-windows-1.0.3.msi
- kdoc documentation: http://www.kite-language.org/docs/kdoc-1.0.3/ (as tarball)
- General Kite documentation: http://www.kite-language.org/docs/kite-1.0.3-docs/ (as tarball)
- Kite API documentation: http://www.kite-language.org/docs/kite-1.0.3-api-docs/ (as tarball)
Issue tracker URL (for bug reports): http://trac.kite-language.org/report/1
Getting help: http://trac.kite-language.org/wiki/GettingHelp
1.0.2 released
Written by Mooneer Salem on Sunday 1st of March, 2009 in Usage
Kite 1.0.2 has been released.
New in this release:
- Fixed typo division by zero check in System.float.
- Created package building system for Kite packages/modules. (System.package.builder)
- ikt no longer quits when code throws an exception. (ticket #86)
- ikt now outputs return value of computation on completion. (ticket #87)
- map operator support added for System.directory (credit: Michael Edgar)
- file|exists and file|size added (credit: Michael Edgar)
- string|replace added (credit: Michael Edgar)
- Added operator[]= support to Kite syntax.
- System.object|print now respects value of System.file.stdout.
- Added System.object|print_err (print to file handle pointed to by System.file.stderr).
- Man pages created for Kite applications.
Download:
- Source: http://www.kite-language.org/files/kite-1.0.2.tar.gz
- Debian packages: http://www.kite-language.org/files/binaries/deb/1.0.2/
- Windows installer: http://www.kite-language.org/files/kite-windows-1.0.2.msi
- kdoc documentation: http://www.kite-language.org/docs/kdoc-1.0.2/ (as tarball)
- General Kite documentation: http://www.kite-language.org/docs/kite-1.0.2/ (as tarball)
- Kite API documentation: http://www.kite-language.org/docs/kite-api-1.0.2/ (as tarball)
Issue tracker URL (for bug reports): http://trac.kite-language.org/report/1
Getting help: http://trac.kite-language.org/wiki/GettingHelp