lua-users home
lua-l archive

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

Hello Mark,

Thursday, December 14, 2006, 2:35:30 AM, you wrote:

MH> The problem is that this isn't safe. How does Lua know that the pointer you
MH> are passing in really is a userdata? For example, it might have been one at
MH> one point but might have since been collected.

Yes, it's unsafe. Lua don't know the pointer whether the pointer is a
real userdata. But programmer should know ;)

And programmer can also guarantee it's not been collected. In my
project, the userdata's pointer only store in another userdata.
And when I store one pointer of userdata in other userdata, I will
store the userdata in the other's environment. (userdata can has a
environment table :)

As Roberto said, "two extra table accesses should make no relevant
difference" . I think it's the reason why this "unsafe" api isn't

Best regards,