lua-users home
lua-l archive

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


Patrick Donnelly wrote:
> 
> I don't see any error in the implementation here. Try this:
> 
>> do
>    T=setmetatable({},{
>     __len=setmetatable({gth=0},{
>      __call=function(o) return o.gth end
>     })
>    })
>    getmetatable(T).__len.gth = 3
>    print(#T)
> end
> 3
> 
> ?
> 

My mistake. I thought Lua would try to return #__len if it was a table.
Of course it does no such thing.

-- 
- tom
telliamed@whoopdedo.org