lua-users home
lua-l archive

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


On Feb 22, 2011 8:48pm, Miles Bader <miles@gnu.org> wrote:
> On Feb 22, 2011 7:44pm, Gaspard Bucher gaspard@teti.ch> wrote:
> > We must not lose sight that Lua is *not* dynamic C. It offers many powerful tools that C-like bindings cannot reflect such as varying arguments, multiple return values, callbacks, variable scoping, memory management, metamethods, tables, etc. All these features can (and should) be used to write bindings that make bound libraries easier to use, more powerful and easier to interface with one another.
> >
> > Lua is not just about not ending lines with ";".
>
> lol, good point (and amusingly stated)...

... but I will say that it often seems natural to write bindings like
this in two layers:

* The lower (call it "raw") interface is a direct reflection of the C
interface that just translates representations, but doesn't change the
"shape" of the C interface

* The upper (exported) interface is a thin layer on top of the raw
interface that changes the "shape" to be more natural to the calling
language. This is often fairly simple, and can be written entirely in
the calling language (so in the case of LuaJIT, would benefit from all
its optimization)

In such an arrangement, since the "raw" layer is a mechanical
translation of the C interface, it's fairly amenable to creation by
automatic tools.

-miles

-- 
Corporation, n. An ingenious device for obtaining individual profit without
individual responsibility.