At the time I gave it a go and managed to get something working where, via two helper functions you could supply Lua code and it would compile it, save it and allow you to re-run it using global variables. After a bit of fiddling it would even return a value from the function [smile]
However, I wasnt happy with the solution, as it required that you have the variables the function was called with visable in global scope and as we all know global variables, while they have their place, are often best avoided.
So, after a break I woke up today with a drive to come up with a more flexible solution which didnt polute the global variables and allowed for as many dynamic variables as required to be supplied.
about 10h and much swearing, crying, confusing and hacking later I have something which works!
I'm still working on the dynamic variables bit, however you can now supply the function with varibles which are set elsewhere and which dont polute the global name space. Its done via the magic of metatables, allowing me to lookup the variable in the orignal global namespace (first) and then a supplied parameters table (second).
It also still requires two support functions in Lua, which while it might not be a great deal I would like to try to remove them and do it via the C-API, as I think its posible, its just a matter of working out how to setup metatables and switch the enviroment on functions when they are used.
Once I've got this nailed down and cleaned up I think I'll follow evolutional's advice and write something about it as I think it might make a reasonable intresting article or sweet snippet, in the mean time if anyone is instrested drop me a line and I'll share the code around [smile]