lua-users home
lua-l archive

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

On Sat, Apr 3, 2010 at 12:35 AM, Vafa Khalighi <> wrote:
>> In what sense?  Do you want to use your compiled C function in Lua, or do
>> you want to convert a C procedure into its equivalent in Lua? ...
> Thanks. I meant the latter.

If you want this in a general sense, see David Given's clue [1,2], but
it's said to be experimental, and I doubt your result will be pretty.
This might be analogous to what Alchemy/LLVM does [5].

I have found that C code can be translated into Lua code in a mostly
mechanical way if want to preserve structure over efficiency.  Even
something like a pointer into a C array can be translated into an
index into a Lua table array.  That was the case with Lua's lstrlib.c
translated into Lua [3], and it appears also with Yueliang [4].  You
can stumble with things like "continue" statements, which Lua doesn't
directly support, so you may need to do some pre-translation