On Wed, Sep 17, 2014 at 9:21 PM, KHMan wrote:
On 9/18/2014 6:35 AM, Stephen Irons wrote:
My assumption is that Lua has been developed by people who
* are reasonable
* have limited time
* make mistakes
For me, it is reasonable that the length of a table with
no positive
integer indices is zero. PiL certainly suggests it; many
examples
would not work otherwise. The authors do not want to
re-write PiL if a
future version of Lua accidentally returns something other
than 0 for
an empty table.
[snip snip]
Two thumbs up for this.
Ref manual wasn't written to pass the documentation standards
of ISO or ECMA or similar groups. If that part isn't tweaked
in the future to make it super-precise, I wouldn't lose any
sleep over it.
Next perhaps we will see a posting with someone getting all
incredulous that the ref man doesn't mention certain
implementation limits and we'll have another thread going
round-and-round-and-round-and-__... (nothing wrong with such
threads, but they seem, so... superficial...)
On 18 September 2014 01:50, <polyglot@---.---> wrote:
5.2 REFERENCE MANUAL
"Unless a __len metamethod is given, the length of a
table t is only defined
if the table is a sequence, that is, the set of its
positive numeric keys is
equal to {1..n} for some integer n. In that case, n is
its length."
*** Conclusion ***: Without a __len metamethod, an
empty table has undefined
length.
[snipped all]
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
I think that there is a legitimate and non-superficial discussion
going on here, even if it never did cross my mind that
`assert(#({}) == 0)` might some day fail.
I believe that it goes something like:
It seems that the reference manual is written in an exceedingly
terse style that approaches a strict specification. [snipped rest]