lua-users home
lua-l archive

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


Another advantage of stripping library prefixes in Lua bindings is that it
automatically allows OO syntax, if the library functions always receive a
handle as the first argument. I've exploited this in my libraries for gdbm,
md5, and pdf.

So, for instance, it's much cleaner to write
	d:digest()
than
	d:md5_digest()
or even
	md5_digest(d)

On the other hand, if the Lua binding uses luaL_reg structs to define the
binding names, then it's pretty simple to traverse it and register the
functions as globals with the correct prefix attached. In this way, you
get both options.
--lhf