lua-users home
lua-l archive

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


2012/11/20 Richard W.M. Jones <rjones@redhat.com>:
>> And as for the "single change", it has a big impact. Whether you pass
>> a valid string or NULL, luaL_register will create a new table on the
>> stack or not.
>
> I think what I don't understand is do I need to add this string
> parameter?  The code seems to work fine at the moment (using NULL), so
> I'm inclined to just leave it alone.

You don't "need" to, but the luaL_register call does two very
different things whether you pass a string or not. Both are
acceptable, depending on your intent. But I don't know your intent
there. A simple luaopen_ function creates a Lua table, put some stuff
in that table, and somehow pass it back to require. That table is then
called a "module". Your luaopen_ function does something completely
different. It is perfectly valid, provided you understand what you are
doing.

To sum it up, what do you intend to do with that call to luaL_register?