|
On Jul 6, 2013, at 10:47 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote: Tim thinks: Not really, I floated the idea that *some* agreed-upon mechanism *might* be useful. I also suggested one (actually two) possible solutions; others have made other suggestions that are equally valid. To address the well-known idioms: -- Using empty tables. Works will within a single Lua state, is more awkward across Lua states as marshaling is needed and the table needs to be manufactured in a "safe" haven such as the Registry, and then made available via an API (and if you are doing all this, you might as well fall back on my light userdata, which is less complex and faster). -- Switch from arrays to manually managed tables of integer keys (or similar), using "n" or some-such meta-managed state to track which "elements" of the pseudo-array are empty. This is fine until you start to wrap higher-level abstractions and want to do things like getter/setting semantics on one of the empty elements, though nil can now do this job if you are careful not to need nil for things like the "nil+error" Lua convention for error handling. There is also of course some performance overhead. --Tim |