lua-users home
lua-l archive

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

One minor note: this can be done with Lua metatables aswell. It's not
limited to userdatum. I'm sure you know that already, but for those
who don't :-)

On 4/19/07, Rici Lake <> wrote:
Sam Roberts wrote:
> On Thu, Apr 19, 2007 at 11:53:15AM -0700, Mark Hamburg wrote:
>> Except that you can't get to userdata metatables from pure Lua. But one
>> could certainly replace pairs with a C function that did this and you don't
>> need to patch the Lua sources to do it.
> Maybe I misunderstand "get to", but  it appears that I can access
> userdata from the io library. Is this a version thing?

You can get the metatable of a userdata if it hasn't been locked
with a __metatable key. Many of us routinely set this key, though,
in order to protect the metatable