lua-users home
lua-l archive

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


Hi,

John Belmonte wrote:
> 
> The index tag method is a sub-case of gettable and can be removed, reducing
> the complexity of tag methods and slimming down luaV_gettable in the virtual
> machine.  If the user wants to treat a previously nil  (or any other value
> or type for that matter) index as a special case they can do it with
> gettable, so why go as far as having this in the VM which slows down all
> table reads?
> 
> At least for Sol this would make a lot of sense since 1) tag method
> backwards compatibility was already tossed and 2) global reads go through
> normal table access so the VM's table read is even more of a workhorse than
> Lua.

Hmm...  And I've just added a "newindex" method to Sol ;-)  It's
similar to "index" but called from settable if a new element is
created.

IMHO these two methods are too useful for general Lua/Sol programming
(fallback methods/inheritance, default elements, caches, ...).  In
contrast set/getglobal is mostly used for debugging and set/gettable
for table simulation - nothing that I would use for a typical program-
ming task.  If it were just about minimalism you'd have to remove the
table operators (. : []), the for-statement, the constant initializers,
and so on.

About performance: Yes, Lua4/Sol is slightly slower at globals than
Lua3.2.  But I don't think you can measure a difference between Sol
and Lua4 in any real application (and even if you could, I'm not sure
who is faster :-).  I guess, removing the "index" test would give
below 1% difference in execution speed if you do nothing else than
table lookups.

Ciao, ET.