Re: Key lookup optimizations...

  • From: Lance Thornblad <lance.thornblad@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 1 Sep 2015 15:31:40 -0600

On Tue, Sep 1, 2015 at 3:21 PM, Alex Szpakowski <aszpakowski@xxxxxxxxx>
wrote:


On Sep 1, 2015, at 6:10 PM, Lance Thornblad <lance.thornblad@xxxxxxxxx>
wrote:

What's the difference, when you say C function vs. Lua C API function?

C function:

int foo(int bar) { return bar * 3; }

Lua C API function:

int luafoo(lua_State *L) { int bar = luaL_checkint(L, 1);
lua_pushnumber(L, foo(bar)); return 1; }

You can call C functions directly from inside LuaJIT by using its FFI.
More info is here: http://luajit.org/ext_ffi_tutorial.html


Now I see. Thanks for your examples. :)

Other related posts: