lua-users home
lua-l archive

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

* On 2014-06-18 16:37:21 +0200, Andrew Starks wrote:
> We have our nanomsg binding that we recently remade. It was very C heavy
> and now it's the opposite. We're making an "nml.core" that looks *pretty
> much* exactly like the C API. The higher level binding wraps it in a
> Lua-esque API.
> If you have made bindings this way, how far do you take the idea of
> sticking to the C API in your core layer?
> Do you strive for perfect adherence to the original C documentation? Do you
> change things like "-1" or "0" to "false", where appropriate? Do you use
> multiple returns where their API is using pointers?

I usually try to adhere to Lua idioms as much as possible, even creating
OOP like API's where appropriate, for example for API's which have an
opaque context type which is created, and then passed to all functions.

I try to end up with a consistent mapping between the C and Lua API's,
so that the original C library documentation still applies, while
keeping a few simple rules in mind about how to use them 'the Lua way'.

This is of course much more simple for C API's which are already