Re: Next Lua (5.2) feature request : slicing
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Next Lua (5.2) feature request : slicing
- From: Asko Kauppi <askok@...>
- Date: 2006年11月25日 00:03:09 +0200
Would you be okay in making this via token filters?
For the cases you point out, it could:
mat[exp1,exp2] --> getmetatable(mat).__index(exp1,exp2)
For a function returning multiple values, it could not, but we can
rule that out, right?
-asko
On 24.11.2006, at 21.51, Shannon Stewman wrote:
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) ]