lua-users home
lua-l archive

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


On a note unrelated to the original question - this reminded me of
something I couldn't figure out how to do in Lua - determine a
variables type.

Specifically I was trying to write code which took an arbitrary table
and output a .lua file which, if executed, would reload that table.

E.g.
table = {}
--fill the table with an assortment of keys and values of different types
table.itsAString = "aString"
table.itsANumber = 45
table.itsASubTable = { subString = "subString" }
table.itsABool = false
--dump the table to file
DumpTable(table, "someTable.lua")

--reload it
table = nil
dofile("someTable.lua")
print(table.itsAString)


However, I couldn't figure out how to recognise the sub-tables and
recurse over them, nor any way to identify and ignore userdata
elements. Does Lua provide such a mechanism?

On Thu, 24 Feb 2005 20:29:00 -0300, Romulo Bahiense
<romulo@icontroller.com.br> wrote:
> > It's good though, I like the way it works, what I know of it..
> 
> Me too.
> 
>         IMO, Lua's way is much better than most implementations in others
> languages -- such as PHP, where you have to use functions, hacks or
> uncommon (bizarres IMO) operands to test a variable's type, value or
> even it's existence at all.
> 
> I never get tired of saying how much I love Lua :)
> 
> --rb
>