lua-users home
lua-l archive

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


On Mon, Sep 27, 2010 at 01:01:36PM -0600, Tim Mensch wrote:
> >Conversely, the number of people who turn up on #lua because they can't
> >get some automatic binding tool or C++ wrapper to do what they want is
> >astonishing.  Especially when doing it using the C API is often a 5-line
> >job, most of which is boilerplate.
>
> Not anywhere near five lines if you're doing anything complex; 

My argument is to not do that, then :)

> just exposing one function? Sure. No point in adding complexity. For
> functions where I need variable parameters or similar, I still use
> the C interface. But if you're exposing nearly a hundred class
> member functions with varying parameters to Lua (e.g., Playground
> SDK)? I'd recommend a wrapper every time.

Again, I'd suggest that a class with hundreds of member functions might
require... reworking.  Additionally, such verbatim bindings often result
in disappointing experiences when used from inside Lua, which is why I
always implement a wafer-thin binding, and then make everything look
lovely from Lua.

> AND...the wrappers available leave some usability (or performance)
> to be desired. On this we can agree. :( In this particular case, the
> LuaPlus Call Dispatcher (which can be used without using LuaPlus,
> btw) is one of the easier to understand -- its interface looks very
> much like the standard Lua C interface, only it can takes class
> member functions and a "this" pointer instead of only global C
> functions.

Only global C functions?  I'm not sure what you mean by this.  Lua's C
API certainly doesn't limit you to binding C functions with global
names.  You can even bind functions with no name at all, assuming their
expect and return the right things.

B.