lua-users home
lua-l archive

Re: Lua 5.3 `ipairs` considered perilous

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


Hello Dirk,
2016年02月16日 18:19 GMT+03:00 Dirk Laurie <dirk.laurie@gmail.com>:
> Example 2. Plugging holes in lists of numbers.
> x = setmetatable({5,9,nil,6,nil,nil,3,1},
> {__index = load"return 0/0",
> __len=load"return 8"})
> print(table.concat(x," "))
> However, try this:
>> for k,v in ipairs(y) do print(k,v) end
> and see what happens.
Don't the supplied __len and __index explicitly supply contradictory data?
Best regards,
-- 
DoubleF

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