lua-users home
lua-l archive

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

On 2013-06-28 6:47 PM, "Tim Hill" <> wrote:
> And yes, of course you can store empty into an array (I believe I did answer this). As I stated, "empty" to my mind is simply a regular Lua value that is not equal to any other value except itself. So it can be used as a value, a function argument, a return value, a table key etc etc. Doesn't seem too complex a concept to me, but maybe I'm missing something obvious...
> --Tim

That sounds like you're describing nil. What difference is there between empty and nil except that one can be stored in a table? That seems a lot more confusing than nil itself.
It can help to rethink how tables work. It's not true that a table can't contain nil - it contains nil in every key that doesn't have something else in it. The problem is that leaves no way to iterate over keys that contain nil, since you'd never know when to stop - there are an infinite number of them in every table.

Like I said before, I do think there's benefit to having a single standard "empty" value across the entire Lua state, so that each module doesn't have to have their own - I think this was the main point you intended to make. I just don't see why it needs to be a new "special" type, and not just a global variable created by the standard libraries, just like string and math, pointing to an empty table or userdata.