lua-users home
lua-l archive

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

On Sunday 30 January 2005 7:47 pm, PA wrote:
> > If you want to access this magic number from the C side, you can do so
> > with lua_topointer for several (not all) of the data types. It's
> > extremely rare to need to do this, though; what are you using the
> > "magic number" for?
> Has a hash code. I would like to access this from Lua though.

you can compare any kind of value for equality:

a = {}
b = {}
print (a==b)                --> false
c = a
print (a==c)                --> true

or use anything (not just numbers and strings) as table keys:

a = {}
t = {}
t[1] = 'one'
t["two"] = 2
t[a] = "table-keyed"
print (t[a])                  --> "table-keyed"
print (t[b])                  --> nil
print (t[c])                  --> "table-keyed"

if you think about it, it's equivalent to using the 'address' of a table, but 
without explicitly getting the pointer (but i guess that equality test is 
just a pointer comparison for most types)


Attachment: pgpdgYJYIrRUG.pgp
Description: PGP signature