[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How close to C do you make your binding?
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 18 Jun 2014 20:03:10 +0200
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.