lua-users home
lua-l archive

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


On 10 May 2010 16:26, Juris Kalnins <juris@mt.lv> wrote:
> Actually, it would be more powerful to have [] operator take arbitrary
> number of
> values, just like () does.
> Then:
> x.y.z --> x[y,z] --> x_metatable.__index(x,y,z)
> x.y.z = v --> x[y,z] = v --> x_metatable.__newindex(x,y,z,v)
> x[] --> x_metatable.__index(x)
> etc.
>
> And have default behavior forward indexing calls to nested
> elements, just like it works now.
>
> This would allow a simple way to implement things in the wishlist,
> plus simplify many cases that currently require use of proxy objects.
>

That is a very cute idea actually, and is something I wouldn't mind seeing.
As mentioned, this would make matrix operations so much more easier,
as well as opening up a whole new class of cool things to do..
Its seems to be quite backwards compatable, only changing what is
passed to __index and __newindex...
Can anyone come up with any issues?

Daurn.