[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C arrays as Lua tables
- From: Dimitris Papavasiliou <dpapavas@...>
- Date: Mon, 27 Feb 2012 02:28:49 +0200
> Out of curiosity, how does this compare to LuaFFI's [1] array and structure
> manipulation?
I'm not familiar with LuaFFI but from what I understand from the
description its purpose is to allow a programmer to mix Lua and C
code. LuaFFI therefore has a much larger scope but it inevitably
introduces all of C's complexity into Lua to achieve that. This
module attempts to use Lua's simple and elegant table interface to
manipulate C arrays so the division between the host application and
Lua is kept intact. Core functions (like for instance image synthesis
algorithms, filters etc.) can be implemented by C programmers in C and
used by Lua programmers in Lua.
This could be done just as well of course by exposing the objects
(images, sounds etc.) as opaque userdata, the only thing this module
does is make the object transparent to Lua so that you can still
manipulate individual elements, rows and blocks in a way that is
natural for Lua. So in a way you get a mix of both the efficiency of
C and the simplicity of Lua. At least these are the uses I've thought
of that led me to write it (I needed a way to represent textures,
sounds, triangular meshes and other game-related stuff of my C core in
a way that would be amenable to manipulation from Lua).
Dimitris