lua-users home
lua-l archive

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


> > Matrix accessor is my big big pain!!! The option M[x][y] is highly
> > inefficient but somewhat convenient. I'm using the direct access
> > M[M.pitch * y + x] for optimized routine but I propose the syntax:
> > 
> > m:get(i, j)
> > 
> > to the user. Quite ugly but I don't have anything better.
> 
> How about using __call and writing m(i,j)?

That's fine for getting, but not for setting (__call cannot be used as
l-value). Moreover, you might want to reserve __call for other semantics: in
Numlua, m(first, last, step) returns a slice of matrix `m`, for instance
(Numlua uses m[i][j] for getting and setting entries).

Cheers,
Luis

-- 
Computers are useless. They can only give you answers.
                -- Pablo Picasso

-- 
Luis Carvalho (Kozure)
lua -e 'print((("lexcarvalho@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'