lua-users home
lua-l archive

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


> 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.

Right. Runtim ehashing is necessary because tables can be dynamically
modified using (for example) strings as field names. For example, you
have no way of knowing at (pre)compile time where to look for
table["foo"], so you have to build in a lookup algorithm.
Actually, globals are accessed by hashing too, like table fields.

--
Vincent Penquerc'h