lua-users home
lua-l archive

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



On Nov 21, 2006, at 4:53 PM, Mike Pall wrote:

http://lua-users.org/lists/lua-l/2004-11/msg00083.html

I would very much like to see those opcode statistics for specifically numeric code. My one source of constant frustration with Lua is how its syntax doesn't really work with common matrix/ vector notation. Writing code in Python feels much more natural; this is primarily due to slicing and multiple indexing (that is, mat [i,j]).

I know that I can write various "fancy" things that make mat[i][j] =2378 work, but I don't like creating intermediate objects where we don't need them.

What I would like:

A straightforward extension to indexing that allowed a library to implement mat[i,j] by allowing multiple arguments to __index and __newindex. This would eliminate proxy objects (of the sort mat[i] [j] requires) and not require painful manual addressing (the highly annoying mat[j*NCOL+i]).

Slicing can easily be done with the existing syntax:

mat1[ slice(1,3) ] = mat2[ slice(4,6) ]

which extends nicely to 2+ dimensional arrays:

mat1[ slice(1,3) , slice(1,3) ] = mat2[ slice(4,6), slice(5,7) ]

Cheers!

--
Shannon Stewman         | Let us walk through the waning night,
Caught in a whirlpool,  | As dawn-rays tickle our toes, the dew soothes
A quartering act:       | Our blistered soles, and damp bones stir
Solitude or society?    | As crimson cracks under the blue-grey sky.