Many people do not realise Lua is actually a compiled language because of ComputerCraft's open source ethic.
As I am big supporter of the ability to have closed source and compile programs, have spent the last 30 minutes writing a very basic compiler for lua code. As the default shell cannot outright run compiled lua because of the way it's set up, I also created a basic way to run the compiled code.
Really they are both more like wrappers for existing functions, but nonetheless these are the first compile-run programs for CC that I am aware of. Anyway, for those interested, I am submitting these programs (and their included functions) for public use.
Limits:
You may use the code provided as is or you can extract the individual 'compile' and 'run' functions for use, or even rewrite them to your own suiting, but you should give credit by providing the header provided in both files when you use the code in other files or projects.
It would also be appreciated if any inspired works mention this post or link to it or the files.
The Files:
Compile.lua: http://pastebin.com/S520NYMV
Run.lua: http://pastebin.com/xjBgXmfy
Usage:
Compile.lua inFile outFIle
Run outFile
Afternote:
Feel free too integrate the system into the shell, providing you leave credit..
I recommend making the shell test a file for the 'LuaQ' header and making it choose which loadfile function to use based on that.
Versions:
Version 1.0.1 - First working versions
Version 1.0.2 - Bug Fix.Added sleep to fix yielding. Credits to pingoleon60.
Version 1.0.3 - Speed Enhancement. Replaced sleep with queue event. Credits to theoriginalbit
Version 1.0.4 - Speed Enhancement. Added if statement to only yield when required.