[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Performance vs flexibility
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 8 Jan 2015 11:01:54 -0200
> I just wondering what's behind that design decision, I mean what's the pro and cons of having an hash table for globals instead of a simpler array?
I'm not sure what you mean by "simpler array".
If you mean that each global would be given a number and then access to it
would just index an array with that number, then of course the same name
has to be given the same number and that number depends on *when* the global
is created. This would complicate precompiling scripts via luac. (I think
the earliest versions of luac had to solve this problem.)
In any case, you'd still need to find the number given the name and a
hash table is ideal for that.
You might want to read the source of the early versions of Lua and see
how globals are implemented. Get the lua-all package: