Re: array access "A[i]" and luabind

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Sebastian Wolff wrote:
> Hi,
> 
> I try to enable array index in my classes for linear algebra.
> 
> At least the calls
> 
>   object[ integer key ]
>   object[ table key ]
> 
> should work. The idea is to make index access as general and convenient 
> as possible by providing a syntax like
>    Vector[i]
>   Matrix[i][j] -- a switch creates a temp. object onto the i-th row if ncols>1
>   Matrix[{i,j}] -- a second key type (table) which allows common keys 
> for vectors AND matrices
>   Vector[{i,0}]
>   -- both instantiations, Vector and Matrix, should be of the same data type
> 
> Somehow it is not possible to change the __index and __newindex methods 
> using luabind. Is there any way to simulate such a behavior or is 
> support like this planned?

Unfortunately there is currently no way to do this. Support for
overloading __index and __newindex is planned for 1.0. Adding this
shouldn't be terribly hard, so it could be one of the first things
addressed after the 0.9 release.

-- 
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.