lua-users home
lua-l archive

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




On 20/08/16 08:54 PM, Ross Berteig wrote:
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.


My goal is to stop the threads complaining about length calculations and holes and stuff.

If you were paying attention to the mailing list recently, you should know we had multiple threads about tables with holes. This could be solved by making length an unknown.

We already have ipairs() vs #, we just need to expand that inconsistency to more parts of Lua.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.