[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua table implementation
- From: Philippe Lhoste <PhiLho@...>
- Date: Tue, 03 Oct 2006 10:10:20 +0200
I use a language named AutoHotkey (or AHK), which allows to automate
Windows applications.
It still has lot of rough edges in its syntax, but it is useful to help
day to day tasks.
Currently, it has only a very primitive array system, which is
interesting by its concept, but is quite limited:
In AHK, if var contains foo, array_name_%var% becomes the array_name_foo
variable. So we can have numerical arrays (v = 1, a%v% is a1, like a[1])
and even associative arrays (limited to the range of characters allowed
in variables names...).
A big limitation is that these arrays are hard to make local, and nearly
impossible to give as parameters to a function or to return them.
So the author of the language plans to implement true arrays.
I believe he should go one step further, and implement associative
arrays as well. And naturally, I took a look at the way tables are
implemented in Lua, knowing they are efficient and easy to use.
Of course, I have (re)read the Implementation of Lua 5.0 paper, and even
the Reducing the retrieval time of scatter storage techniques one. The
later is a bit too theoretical for my taste, but I suppose I could
manage to get something out of it.
I also took a look at ltable.c, but without knowing intimately the
internals of Lua, it is hard to follow (gnode, gkey?).
I believe that with lot of work, I can flatten this and make it usable
for my needs, but I thought I should first ask if somebody did something
like that before, so I won't reinvent the wheel (or recut it to make it
oval...).
In other words, do somebody know some alternative implementation, or has
done some detailed analysis of this algorithm or have some other
material I could use?
In all cases, I will share my findings with the community, of course.
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --