lua-users home
lua-l archive

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

> Has anyone done a non-hash array implementation for the Lua 4.0 compiler?
> Something on the order of (I'm making up syntax):
> array myArray[10]  -- All 10 elements set to nil by default
> myArray[10] = 5      -- Array index 10 becomes the number 5.
> I know that using the [] for array access would be ambiguous... is it a
> table or an array?  But for the sake of this example, please bear with me.

If you look at the table implementation in lua, you'll be pleasantly
suprised to discover that for numeric indexes, it actually is an array (it
doesn't use hash values because it can't).  It's really amazingly clever.

What lua is really lacking is a sorted dictionary or tree.  It's really
impossible to implement any sort of sorted table.