[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How close to C do you make your binding?
- From: Coroutines <coroutines@...>
- Date: Wed, 18 Jun 2014 23:25:31 -0700
Not sure where we are in this thread. Thought I'd add that I like
making 1-to-1, direct bindings to the C library I'm exposing a Lua
My reasoning is this:
I hate writing docs. Even if the docs are great users get turned off
if the docs aren't pretty or marked up in a way that makes them want
to read the docs. It's nice to point at a plethora of existing C
documentation for the bindings you make. I myself have been making a
cross-platform socket library for Lua (just BSD socket bindings). I
do basic type-checking, and only some parameters are optional (e.g.
listen(socket, backlog) -- backlog is optional). I originally wanted
to make my own socket library because while I liked luasocket I was
displeased with the docs -- I didn't know what errors to expect from
certain functions and I just wanted to use the C tutorials I'd read
for socket programming.
Eventually when I'm done I plan to release the direct bindings under
its own unique name, but I'll have an included .lua to provide the
same interface as luasocket -- so again I won't have to write my own
I like this method of never-doc-writing. On the whole it's easy to
build over an unforgiving C interface to something friendlier in pure
Lua, it's harder to do the reverse.