lua-users home
lua-l archive

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

On Oct 2, 2011, at 12:55 AM, Lorenzo Donati wrote:

> Very, true.
> This is IMO a big newbie gotcha: Lua tables are so "high-level", i.e. they can be easily used to implement lists, trees, maps, stacks, etc., that one can easily think they should provide a much fatter interface (the common problem of getting into Lua's spirit).
> It's not easy to grasp initially that one can use OOP techniques to turn a generic table into, say, a "stack object", with usual push/pop methods.

Which leads to the argument that the "problem" is that Lua tables are too powerful. So often they are powerful enough that they just solve the problem. Much of the rest of the time, they seem powerful enough until you realize that they aren't quite. And then you come and complain to the list about tables being broken and about how Lua has to change. Maybe the change is that tables should be less powerful and people should be forced to roll their own data structures.

Not that I buy that argument.

Still, it does point to perhaps a getting started FAQ that would disabuse people of notions that will get them in trouble -- "You can do a lot with tables, but understand their limits and build data structures as you approach those limits."; "Metamethods are fallbacks not overrides and though they may seem like methods in an OOP language, they don't always behave that way."; etc. Then the real trick is to write this all without it turning into something like JavaScript: The Good Parts which contains a lot of warnings about the "bad" parts where JavaScript is just bizarre.