Closed rbartlensky closed 5 years ago
Just because Lua has the global _ENV
var doesn't mean that we have to store things in a table, which is likely to be very slow (register lookups are a lot faster than hash-based table lookups!). We can have a special table type that dynamically looks up the value of variables, for example, amongst other tricks for dealing with this.
This suggests that _ENV
has to work just like a table. I am going to think about this in more detail before raising a PR for the _ENV
implementation.
"Has to work like a table" doesn't mean "has to be a table". So long as the Lua programmer can't tell the difference, you can optimise things under the bonnet in whatever way you want.
Ready for another review.
Please squash.
Squashed!
LuaTable
s can now be indexed by anyLuaVal
. This is necessary because global variables are all kept in an_ENV
variable which is a global table. For instance,x = 2
translates to_ENV["x"] = 2
. This is also why this PR introduces theLuaString
type.More information about why I forked the
gc
crate can be found here.