lua-users home
lua-l archive

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


But to create a Lua-esque API needn't many C codes. what if to write
as little C as possible and create a Lua-esque API?

lua-nanovg[1] is a binding to NanoVG[2]. it just like the plain C
wrapper codes, but it really does the magic to make the final
interface Lua-esque.

[1]: https://gist.github.com/starwing/10666487
[2]: https://github.com/memononen/nanovg - a tiny antialiased 2D
vector drawing library

2014-06-19 2:38 GMT+08:00 Andrew Starks <andrew.starks@trms.com>:
>
>
> On Wednesday, June 18, 2014, Coda Highland <chighland@gmail.com> wrote:
>>
>> On Wed, Jun 18, 2014 at 11:03 AM, steve donovan
>> <steve.j.donovan@gmail.com> wrote:
>> > To stick to the original API is missing an opportunity to make that
>> > API better and more accessible to others. It's a common strategy to do
>> > a minimal binding (or use FFI) and then build something more elegant
>> > on top of that.
>>
>> The context of the discussion IS said minimal binding to build on top of.
>>
>> I will point out that such syntactic points as multiple return values
>> and error handling are also the kinds of changes I'd do; I'd
>> overlooked those in my discussion because usually I'm working with
>> stuff that's already object-oriented instead of idiomatic C and
>> therefore those considerations aren't nearly as necessary.
>>
>> /s/ Adam
>>
>
> Thank you. This was the heart of the question. We're writing a very
> Lua-esque API and exposing the "core" object inside. Our goal was: as little
> C as possible.
>
> I wanted to know if others were writing the "core" layer so that all of the
> function arguments and return values matched, whenever possible, with the
> idea being that *any* inconsistency would be a burden. For example,
> accepting "0" from the C function, when the Lua equivalent would return
> something "false-y"
>
> It sounds like doing the easy things that don't create a lot of C code is
> more common.
>
> -Andrew



-- 
regards,
Xavier Wang.