lua-users home
lua-l archive

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


Hi

there is really a significant difference:

Whatever you assign to an array (or object) member in JavaScript, it stays in the array/object. Assign null, or even undefined, doesn't matter; it's there and you can enumerate it.
You need to explicitly delete() it.

This is kind f confusing if you come from C++, in JavaScript delete() does not kill the data, it kills the variable; the data may be referenced else where and survive.
I do not really like the doubled feature undefined - null either.

--
Oliver


Am 21.07.2016 um 21:28 schrieb William Ahern:
On Thu, Jul 21, 2016 at 12:13:40PM -0300, Rodrigo Azevedo wrote:
In face of recent (long) discussion about "Lua arrays", I would request a
simple few lines of real world examples where the use of "Lua arrays with
holes" is significant.
The first use case that came to mind was JSON deserializers, where the
obvious mapping of null to nil causes problems with arrays.

But I think that's irritating mostly because superficially it _seems_ like
such a trivial (and trivially fixable) mismatch between Lua and JavaScript
type semantics, but as the thread has shown it's not trivial at all. I
wouldn't use this case to argue for change in Lua.