lua-users home
lua-l archive

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


On Fri, Feb 12, 2010 at 12:29 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> You can get hold of the metatable used by file objects, as you may
> have figured out:
>
>> f = io.open 'LuaArray.java'
>> mt = debug.getmetatable(f)
>> = mt
> table: 00366C08

This is a tangential point, but you actually *don't* need to use the
debug library's version of getmetatable() to get at the metatable of a
file object. Unlike setmetatable(), which will only allow you to set
the metatable of a table, getmetatable() will get the metatable of any
value. The only exception to this is if the metatable has __metatable
set - but this is not the case for file objects by default.

-Duncan