lua-users home
lua-l archive

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


On Wed, Jun 18, 2014 at 7:58 AM, Andrew Starks <andrew.starks@trms.com> wrote:
>
>
> On Wednesday, June 18, 2014, Coda Highland <chighland@gmail.com> wrote:
>>
>> On Wed, Jun 18, 2014 at 7:37 AM, Andrew Starks <andrew.starks@trms.com>
>> 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?
>> >
>> > -Andrew
>>
>> My goal, when I do such a direct binding, is to make it to where
>> there's almost no documentation necessary -- that is, you can use the
>> original C docs directly with only minor changes (mostly syntactical).
>>
>> /s/ Adam
>>
>
> That detail is the question, though. What syntactical allowances do you make
> for variance? Examples?

Well, obviously there's just the syntax of the two languages being
different. :P And then of course there's the difference between manual
memory management and garbage collection. Then sometimes callback
handling is necessarily different by virtue of the abilities of the
binding.

Beyond that, I really do try to keep it to a minimum. If I want to
sugar it up, that gets done at a higher level.

I DO consider exceptions for cases where it might be REALLY tedious to
implement the API so precisely, and I don't have a problem with the
bound API exposing functions that don't exist in the original language
(as long as I can still directly translate example code).

/s/ Adam