lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great steve donovan once stated:
> On Thu, Mar 20, 2014 at 9:36 AM, Florian Weimer <> wrote:
> > The ROOT project at CERN has implemented this:
> > <>
> Ah yes, comes from the clang project - very promising!  It means that
> I don't ever have to bother with UnderC again, which is good news.
> But, to return at least nominally to Lua, this REPL is implemented by
> clang and so should be able to handle loading the Lua headers.  If it
> also does FFI linking against the shared library, that will give
> people a nice testing ground for playing with the Lua C API, one
> function at a time.

  You can get close to this with the module [1] for Lua.  This
will allow you to compile C code from within Lua and have the results
immediately available for use:

Lua 5.1.5  Copyright (C) 1994-2012, PUC-Rio
> cc = require ""
> test = cc.compile('test',[[
>> #include <stdio.h>
>> #include <lua.h>
>> #include <lauxlib.h>
>> int test(lua_State *L)
>> {
>>   printf("Hello from C!\n");
>>   return 0;
>> }
>> ]]
>> )
> test()
Hello from C!

  It's based upon my bindings to TCC [2][3], and it also extends the module
system so you can load C modules directly into Lua from source (only works
for Lua 5.1 currently).



[2]	A very fast C compiler that can be linked into any application.