lua-users home
lua-l archive

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

On 10/5/11, Luiz Henrique de Figueiredo <> wrote:
>> Imagine you want to build a tree datastructure where you can store an
>> arbitrary Lua value per node. How does one accomplish such a goal
>> without instanciating a bunch of tables in the process?
> What is the problem with a bunch of tables?
>> Wouldn't a simple, fixed size, integer indexable (1 based, of course
>> ;-) ), array type be better suited for the role of building block?
> If you want Fortran, you know where to find it... :-)
> Plus Lua does very well on these arrays already...

Well, I believe you. Not having performed any benchmarking I wouldn't
argue about the overhead of the rest of the table implementation; it
was just a gut feeling :-)

It's just that sometimes I feel that it gets kind of convoluted to mix
userdata and the other Lua types because you have to jump a few hoops
if you want to, say, store a table in a C struct.

I'm ready to believe that, in those cases, I'm simply not doing it
"the Lua way (tm)" and that's the point of this thread that you summed
up spot on: there's how we do it and how others do it, and it's better
to learn the right way than to complain about it.