lua-users home
lua-l archive

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


I think the primary benefit is having an array work like an array. So if you could essentially have a "writer" mark an array as of size X, and then let the "reader" use "#" to get this, that would also work.

Both "empty" and declarative array sizes provide a way for a structure creator to communicate to a reader information about the structure, using a mechanism (the # operator) favored by Lua. To my mind all the workarounds fall into two categories:
-- A private contract that communicates this outside of # … which seems to suggest that # is not very useful.
-- Using a metatable to create custom behavior, which preserves # semantics but requires the writer to perform considerably more work.

My feeling was that simply adding a standard way to do this avoided both of these work-arounds.

Anyway, clearly the issue has been decided, though perhaps by a less than impressive process.

--Tim


On Jun 30, 2013, at 3:55 PM, Parke <parke.nexus@gmail.com> wrote:

On Sun, Jun 30, 2013 at 1:33 PM, Tim Hill <drtimhill@gmail.com> wrote:
The only APIs were two small C functions exposed to Lua:
x = getEMPTY()
b = isEMPTY(x)

Hi Tim,

In terms of utility in your projects, how does the above solution compare to (hypothetically) extending Lua to force the "array" portion of a table at be least X large, on an adjustable, per table (or per metatable) basis?

In this hypothetical case, nil would mean empty, but you would not have to worry about the array portion collapsing due to sparsity.

In other words, other than avoiding unwanted table collapsing, are there other benefits to empty?

(I have no idea how much work it would be to make this hypothetical extension to Lua, nor how palatable other Lua users would find it.)

-Parke