lua-users home
lua-l archive

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


> 
> one major difference between light- and full- userdata is the equality test.
> 
> light userdata is tested by value while full userdata is tested by reference.
> 
> this make big difference when you need to use them as table keys.

hmmm, I’m thinking about that one. So a light userdata is really a void* pointer as a user value, so assignment just copies the “value” which is the void* pointer. Two values that have the same pointer, and will be equal. A full userdata is a garbage collected wrapper around a void* pointer, so assignment just copies the reference to this. Two values that refer to the same full userdata will be equal. Same semantics.

So I’m not not sure how they are different? Do you mean that a light userdata and a full userdata to the SAME void* will be different? If so, then yes, but that’s *really* not a good thing to do anyway.

—Tim