lua-users home
lua-l archive

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


On Wed, 19 May 2010, Doug Currie wrote:
> On May 19, 2010, at 11:57 AM, Tony Finch wrote:
> >
> > nil_t = {}
> > setmetatable(t,{ __index = function () return nil_t end })
>
> Yikes! This seems to break Lua's definition of #
>
> Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> > nil_t = {}
> > t = {}
> > setmetatable(t,{ __index = function () return nil_t end })
> > return #t
> 0
> > return  t[1]
> table: 0x100109640
> >
>
> -- Note: t[n+1] is not nil!

Er, yes, that's kind of the point.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/  【ツ】
FAIR ISLE: SOUTHERLY 4 OR 5, BECOMING VARIABLE 3 OR 4. SLIGHT OR MODERATE.
OCCASIONAL RAIN OR DRIZZLE, FOG PATCHES. MODERATE OR GOOD, OCCASIONALLY VERY
POOR.