lua-users home
lua-l archive

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


On 8/20/2016 3:34 AM, Soni L. wrote:
The first change is to remove length entirely.

No.

The `#` operator as defined in 5.1 is useful, is implemented, and is tested across 5.1, 5.2, and 5.3.

If it not useful to you, don't use it. It's presence is not causing harm, other than the persistent threads by you that demand some change or another. Stop doing that, and the frontier/length operator does no harm.

If any change to it is to be made, I would ask for two cosmetic documentation changes, and one additional function in `table`.

First, I would ask that the definition of `#` return to the precision it had in 5.1 which is how it is actually implemented in all three versions.

It could also be formally named "frontier", and exposed as table.frontier() for the benefit of data structure libraries that would like to define __len to suit their model and still have the original behavior handy for internal use.

The last cosmetic change I'd recommend is to find a new name for the internal implementation detail now called "array part" vs. "hash part" of a table. Yes, the optimization is for tables used like arrays or sequences. But the name is confusing newcomers into imagining all kinds wrong models of what tables are and how they work. I don't have a better name at hand to suggest, unfortunately, so that particular bike shedding exercise can be deferred indefinitely.

....

All the rest is moot.

I believe these changes will really help w.r.t. arguments about length.

There is no argument. Length is by definition what `#` returns. If that definition doesn't work for you, then implement your own class over a table, which since 5.2 is easy to do using __len.

Please stop trying to break the language for everyone else in pursuit of a goal that only you want.

--
Ross Berteig                               Ross@CheshireEng.com
Cheshire Engineering Corp.           http://www.CheshireEng.com/
+1 626 303 1602