lua-users home
lua-l archive

Re: [ANN] Lua 5.2.0 (work2) now available

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


> __len is still able to return non number values. What is the position 
> about that? Is that the desired behaviour?
__len can return any Lua value:
for k,v in ipairs({true,print,"hello",{},io.stdin}) do
	a=setmetatable({},{__len=function() return v end})
	print(k,v,#a)
end
1	true	true
2	function: 0x9bbdfd0	function: 0x9bbdfd0
3	hello	hello
4	table: 0x9bc2240	table: 0x9bc2240
5	file (0x2e5420)	file (0x2e5420)

AltStyle によって変換されたページ (->オリジナル) /