lua-users home
lua-l archive

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




On Wed, Sep 17, 2014 at 9:21 PM, KHMan <keinhong@gmail.com> 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. Perhaps some additional normative / supporting text might be considered in certain areas. These would be areas that would be difficult to grasp for those that don't have a computer science or math background (table.icopy comes to mind, for me).

I've always thought that the reference manual was written to sell more copies of Programming in Lua. That's an understandable reaction, even though I am certain that it isn't accurate, considering that I live in America. That sort of thing is being done to us all of the time. :)

-Andrew