lua-users home
lua-l archive

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


On 9/16/2013 5:57 PM, Sean Conner wrote:
> Another thing I've found (by doing Lua bindings by hand) is that a
> mechanical approach really doesn't make for good Lua bindings. 
> ...
> Doing it by hand, I did [1]:
>
> syslog('notice',"The foo is %s",status)
>
> which is MUCH nicer (IMHO) than other syslog() interfaces for Lua
> I've seen.

A hybrid approach works really well. Using Dub I have dozens of automatically generated bindings, but when a case like the above comes along I simply override THAT binding with one that's more Lua-friendly.

For some libraries there can be dozens (or hundreds?) of functions that can be automatically bound for every one that needs a customize interface. I'm sure others are the reverse; depends on the application.

And doing bindings that involve C++ classes being bound as Lua "objects" involves a LOT of code I don't want to write a dozen times for a dozen classes; using a generator like Dub that lets you write template code for each kind of binding, so if I decide to change my binding technique, I can change it in one place, regenerate bindings, and have it work that way everywhere. Yes I could hide that kind of binding in C macros, but it still involves boilerplate that I need to write, but that's just a "dumb" version of code generation. Customized code generation is awesome when it works and it's optimized for your use case.

Tim