[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A fast array implementation
- From: "Ben Cooley" <benc@...>
- Date: Wed, 18 Apr 2001 01:03:05 -0700
> 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 -- All 10 elements set to nil by default
> myArray = 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.