lua-users home
lua-l archive

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


What's wrong with t:append(x) ?

Or, if you implement classes via closures, you could even do something like:

t[End] = x   -->  roughly same as t[#t+1], except that t is an object

where 'End' is just a unique value that you use to dispatch on in the __newindex metamethod of t (I can elaborate if anyone is interested). No need for the Lua authors to add anything to get this!

I'm starting to think of programming with raw tables like programming with straight Object arrays in Java -- you don't normally do it unless you're doing something low-level that needs to be super fast, or if you just don't need any convenience methods. I prefer to stick convenience functionality in the methods of a class, not in special purpose syntax. If you have some section of your code that is really speed-critical, you can always cache the methods locally.

-Paul