lua-users home
lua-l archive

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


----- Original Message -----
> How is such thing done in Lua? As far as I read in Lua everything except a
> single variable is stored in a table and accessed by name via a hash
> function. Is this right? Is this done at "compile to bytecode time" or is
> this a mechanism of the virtual machine? I think the last. If so, isn't it
> unfair to compare a language where I just work with adresses in memory to
> one with a more dbms-like structure?

Nothing in this world will be faster than a pointer to a absolute memory
position. And compared with that Lua is very slow ... But.... The key
element is that Lua's tables (or arrays or objects - Same thing - many
names) are dynamic and is purely handled at runtime - So the access method
is hashing and you could compare it to a database..

What I really like about the dynamic structure is that you just assign
values to indexes when you need it.. There is no definition of size or any
definition of members/child.. everything is dynamic.. This call for some
re-education if you are used to working with the static structure...

The downside to this is ofcause performance and the problem with
dertermining the cpu time for a function... Lua will never be "real-time". I
have a very good example.. I buildt a robot that used Lua for the AI... And
I had to stop the robot at some specific times when Lua did
garbage-collection. If I kept it running while the garbage collection took
place the robot might drive off-course in the 1/3 of a second it took to do
it.

/Erik