[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why no pairs() for userdata, __len for tables?
- From: Sam Roberts <sroberts@...>
- Date: Thu, 19 Apr 2007 12:34:42 -0700
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?
% lua5.1
Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio
> = getmetatable(io.stdin)
table: 0x806cae0
> = io.stdin
file (0xb7e8f420)
> return type(io.stdin)
userdata
> for k,v in pairs(getmetatable(io.stdin)) do print(k,v) end
setvbuf function: 0x806cc28
lines function: 0x806cc68
write function: 0x806cdc0
close function: 0x806cba0
flush function: 0x806cbd8
__gc function: 0x806cdf8
read function: 0x806cca0
seek function: 0x806cbf0
__index table: 0x806cae0
__tostring function: 0x806ccd8
Cheers,
Sam