lua-users home
lua-l archive

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




On Thursday, June 19, 2014, Ką Mykolas <kamicc@gmail.com> wrote:
In my personal opinion, writing Lua modules too close C level --- is
just like handycapping Lua developers who are going to use Your
module(s). If developer wanted as low as C level --- he/she would have
chosen C instead of Lua. So, basically, Lua tools, ideas and paradigms
for writing Lua modules. C tools, ideas and paradigms for writing C
modules.

I share your opinion. When I took a stab at writing a nanomsg binding, I paid no mind to the original library. This made for a lot of very complicated C code that I don't ever want to touch again, for as long as I shall live. 

Rule #1: Get thee from C to Lua as fast as possible.

This means that your binding will look very much like C. Where it doesn't, it will most likely be due to memory management, and data types. The other differences are "true" and "false" and multiple returns. Here, Lua can make it less tedious and the amount of variance is probably a judgement call. 

From there, you can, and according to your taste should, "do it all again" by wrapping the core binding around an object model. 

This is the process that we are employing, right now. "nanomsg" is very well done, for this purpose, but I can't imagine a binding for which I would not try this approach first. 

-Andrew