lua-users home
lua-l archive

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


2011/4/18 Michael Gogins <michael.gogins@gmail.com>:
> Overloading the call operator is used in several competitive C++ matrix
> arithmetic packages, e.g. the redoubtable Eigen.

> On Mon, Apr 18, 2011 at 12:28 PM, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
>> How about using __call and writing m(i,j)?
>>

The fortran style notation m(i,j) is very attractive, I would love to
use it but what if m(i,j) is in the left hand side of an assignment ?

m(i,j) = 3.14

I think that you if you provide this syntax it should be valid both to
assign and to retrieve an element.

The "redoutable" eigen package can use this approach because the "even
more redoutable" C++ programming language provides almost any
imaginable black magic about operator overloading. As far as I know
the same thing is not possible in Lua. The assignement operator can be
overloaded with __newindex and the call operator also can be
overloaded but you cannot overload the combination of them. Hey...
what a bright idea! we can introduce the __newcall metamethod to make
it work!!

I will be grateful to the Lua community if this proposition was
accepted for Lua 5.1.5... :-)

-- 
Francesco