lua-users home
lua-l archive

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


hi all.

as we know, lua has eight types: nil, bool, number, string, function, table, userdata and thread.

in Lua, nil and false are (nearly) the same. as number and string are (nearly) the same. but we know, nil is not false, false means "not true", but nil means "nothing".

but, what is number and string?

in perl, number and string are the same. they are "scalar", so we can use number in the place using string, and vice versa. this is just the meanings of the words “number and string are the same".

but in lua, the number and string is not "exactly" the same. e.g. in table index, the number and string is different. that means:

local t = {}
t['1'] = 1
t['2'] = 2
table.remove(t, '1')

can not delete the "1" entry in table. because this is a string key.

Is this behave normal for Lua? in lua, '1' + 1 = 2, but in table index they are diffierent.

maybe we can make all number-like string table index all number, is that more consistency?

btw, is consistency the one of goals of Lua?