lua-users home
lua-l archive

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

> Also, why is l_newpf exposed through the registry?
> `lua_pushcfunction(L, (lua_CFunction)&l_newpf);  /* new-pattern function */`
> I found this really odd: why not expose it directly (so I can link
> against lpeg);

This may change; the idea was exactly to avoid fixed links. Independent
libraries could be independently compiled.

> and why cast it (incorrectly) as a lua_CFunction? Why not a boxed userdata?

It is not incorrect. ANSI C ensures that all pointers to functions are
compatible. That is, if A and B are pointers to functions, we can
convert from A to B and back to A without loss. Now that Lua 5.2 has
light C functions, this looks like an interesting technique to store
pointers to functions in Lua (as long as Lua code has no access to

-- Roberto