[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_newuserdatabox (4.1)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 20 Feb 2002 21:09:37 -0300
>I was curious as to why the naming of lua_newuserdatabox doesn't follow
>the same naming convention as all the lua_push* functions. Tracing
All lua_new* allocated memory. That's the convention.
lua_newuserdatabox was not called lua_pushuserdata because we wanted to
explicitly signal a semantic change that has been introduced in 4.1: Until 4.0,
the rules for equality of userdata were complicated -- equality was on
the pair (pointer, tag). In 4.1, equality is easy: userdataboxes wrap pointers
and equality if based on the box, not the pointer. Perhaps not as convenient
as before, but certainly simpler and safer.
On the other hand, we are considering re-introducing lightweight userdata,
whose creation would be as cheap as numbers, with no allocation needed. This
will avoid the need for ugly hacks such as passing a pointer as a double.