lua-users home
lua-l archive

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

On Monday 28 January 2008, Tom Miles wrote:
> You and Jerome have hit the nail on the head.  They are userdata created
> with different lua_newuserdata calls.  I hadn't considered the
> posibility that they would get seperate hash values if they contain the
> same data, this seems a little odd being as two seperate strings get
> hashed to the same value if they have the same value, but I'll let it
> slide :)

as most inmutable-strings languages, Lua makes all identical strings be the 
same.  that is, at creation time, if a string matches another one, the new 
one is discarded and the old one is used instead.

you wouldn't want this to be done automatically to your userdata, since Lua 
can't know what you'll do with the contents.  IOW, userdata isn't inmutable; 
therefore can't share the same space for several instances.

so, for userdata, the hash source is the pointer, not the content.


Attachment: signature.asc
Description: This is a digitally signed message part.