lua-users home
lua-l archive

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


On Fri, Apr 1, 2011 at 08:12, Tony Finch <dot@dotat.at> wrote:
> Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>>
>> So, a really cheap way to implement 1, 3 or 4 would be welcome, mostly
>> to improve the documentation.
>
> Abolish #t and leave it to the programmer to store the maximum index of
> their arrays.
>
> Tony.
> --
> f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
> Shannon, Rockall, Malin, Hebrides: Southerly or southwesterly 6 to gale 8,
> occasionally severe gale 9 at first, decreasing 4 or 5, occasionally 6. Rough
> or very rough. Rain or showers. Moderate occasionally poor.
>
>

Or just let #t remain as-is, but have it honour the __len metamethod
for tables, so that one is free to define it however they like for
each table. Make it clear in the manual that if your array has holes
and you don't define __len, then #t has no real meaning. Between
__len and __newindex, one can emulate all four of these options.

-- 
Sent from my toaster.