Re: Lua integration suggestions

Tuomo Valkonen <[email protected]>
Newsgroups gmane.comp.window-managers.ion.general
Message-ID <[email protected]>
On 2007-01-29, Thomas Harning Jr. <[email protected]> wrote:
> I was looking through things in Ion-3 and noticed the usage of some
> structures that could be implemented using existing structures in Lua,
> one of the seemingly important elements of the WM.

I'm a bit divided on taking so much advantage of Lua, and keeping the
core of Ion rather ignorant to the extension language used. 

>  1) stringstore
>    This could take advantage Lua's string storage.  

Yeah, I've thought about this...

> Perhaps using a  table in the registry w/ a known index (ex: name).  

That's slow. The C-side references are already indices into the registry.
You could simply directly use the registry, just like the ExtlTab and ExtlFn
references use, but there is a tiny problem: you'd still need to do your 
own reference counting. The ExtlTab and ExtlFn reference IDs are duplicated
for each C-side reference, and so can not be compared. And being able
to compare the strings with simple integer equality is crucial of
stringstore. Lua also does so, by comparing the object pointers, but
these are not available to user C code from the basic API -- and for
a reason: the garbage collector doesn't know of client C code references.
So you'd have to do the comparison as well through the Lua API, and that
has a _lot_ of overhead. Especially as thanks to the extensive use of 
longjmp by Lua, I have to wrap everything in lua_pcall...

So it seems, that for stringstore Lua integration is not an option,
at least not with the present API.

>  2) other rv_tree usage/map/ptrlist/

I actually used to use Lua tables for some uses of the red black trees,
before I added the code to libtu. But then I needed a more efficient
implementation for something (or maybe it was because working with
tables or Objs alone is cumbersome, and I didn't want to extend libextl 
to support arbitrary userdata). And once the code is there, it's better
to use it.

-- 
Tuomo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.