lua-users home
lua-l archive

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


On Wed, Mar 14, 2018, 11:37 Kenneth Lorber, <keni@his.com> wrote:
Undef has been used for different semantics in too many other languages.

Perhaps changing the word "undef" to "deleted" would add clarity?

So we'd have:
        t[i] = deleted

Thanks,
Keni

I like the idea of `table.undef(t, k)`. It's much clearer (it doesn't look like you're storing something in the table, and doesn't make `undef` look like a value) and will still compile in older versions (where the same function can be easily implemented), plus won't break scripts that happen to use `undef` as a name already.

If we weren't concerned about compatibility, I'd go with `delete t[k]` or `delete k in t`. Then you have the possibility of deleting other things, which could be a hint to the garbage collector.