lua-users home
lua-l archive

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




On Wednesday, June 18, 2014, Xavier Wang <weasley.wx@gmail.com> wrote:
I don't like the way using a minial binding and using Lua code wrap on it.

I really agree what Philipp's idea, to follow these rule, isn't need a special lua wrapper code. even if some of it are not easy to implement in C (e.g. bit-mask flags), My idea is to produce a Lua C API style runtime support library[1] to do that things, but not do this in Lua.

Because of that, if all people using Philipp's rules, then all routine you need is the same, that why a common support library is useful. but if you choose to implement it yourself (as Lua code), then users had to see you lua code to know details. you may give document, but if you have document, why you do these yourself?

So, I want a simple binding all write in C, without any Lua code, to use it, simply copy a dll to lua's executable folder. with a runtime library, the binding can write in just one file, easy to compile and disturb.

IMHO, if you follow Philipp's rules, a simple small binding can also Lua-style, needn't Lua wrapper to do that.

[1]: the runtime I write (want to use in auto-binding generator, but I used it in several hand-written bindings currently. the auto-binding generator is difficult to write and maybe not easy to use): https://github.com/starwing/lbind/blob/newinterface/runtime/lbind.c


2014-06-19 2:03 GMT+08:00 steve donovan <steve.j.donovan@gmail.com>:
On Wed, Jun 18, 2014 at 7:33 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> I consider a C binding to be low-level if there is a one-to-one
> function/type mapping between the Lua API and the C API. I usually adapt the
> following:
> ....

These are excellent points; the idea is to exploit the expressiveness
and flexibility of Lua.

C is not a very expressive language (and I speak here as a fan) and
many of its idioms are work-arounds, e.g. returning errors by setting
a 'global' errno and so forth - because of a lack of easy multiple
return, or lack of exception handling, depending on which team you
support.  Or the sad fact (as Stroustrup says) that C arrays don't
even know how big they are. C's expressive weaknesses are legion.

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.




--
regards,
Xavier Wang

These are good points. Maybe that is the difference between "binding" and "library."

I'll still do the library part, but your points emphasize the need to expect that people will often use the binding directly. 

-Andrew