[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Hashing userdata
- From: Javier Guerra Giraldez <javier@...>
- Date: Mon, 28 Jan 2008 07:27:28 -0500
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.
--
Javier
Attachment:
signature.asc
Description: This is a digitally signed message part.