[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Hashing in Lua
- From: Martin_Doering@...
- Date: Mon, 3 Jul 2000 12:20:21 +0200
Today I came back from my holidays. There is one thing, which is not
really clear to me:
I'm a C programmer for some years now. In C I can use structs and then
access single "values" of the struct. I do this by pointers. The compiler
calculates the address, where the actual value is written later at
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?
How are single values accessed? Is it right like this:
b = 5
The VM gets a reference to an adress, where the type of the object
(variable - here a number) is stored. In dependence of this type an
operation is beeing performed. The object b is set to number of 5. So
somewhere in memory a (C-)double of 5 is stored in the end.
I ask this because of thinking on how to write programs in Lua to use
efficient access mechanisms to data. For example: Use more struct like
constructs or use more single global (or not) variables.
This all has, as I think, nothing to do with interpretation or
compilation. It would work the same way in C, if I would use Lua just as
an programming library and use it's data access mechanism.