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.

To avoid initializing all 10 elements to nil first and then filling them in,
we could:

array myArray[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }

Why do this at all when the tables handle it fine?  It's all about speed.
Lua is becoming more and more popular in the gaming arena, and I know I look
for every optimization strategy I can come up with for it (because I want to
use Lua EVERYWHERE!!! :)  But really, it seems like an array implementation
would be a great addition to Lua.

I'm curious to hear other people's insights.

Thanks,
Joshua Jensen
Author, Workspace Whiz - A Visual Studio Add-in
http://workspacewhiz.com/