lua-users home
lua-l archive

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


On Fri, May 22, 1998 at 01:30:44AM -0300, Dan Marks wrote:
> 
> I have written matrix manipulation commands on top of Lua
> and I would like to have them be as Matlab like as possible.
> Is it possible to somehow have Lua read the syntax
> 
> x[-5:5] 

It would be very "meta-language" oriented to have some kind of operator
overloading system in Lua. However, I tend to agree with the
anti-operator-overloading camps in most languages.

> and have that passed to the gettable tag method (or settable?)
> So far I have done this:
> 
> x[{-5,5}]

That's bizarre. I assume you are never actually accessing a table, but
rather just using the fallback. 

> because it will pass a single object (the table) but not multiple
> objects as in x[-5,5].  The reason I want to use this syntax is that
> because there is both a gettable and settable tag method I can
> use the same syntax for assigning and reading a location.  Does
> creating the table for each access of the element slow down Lua
> significantly?

You can have the same syntax be used for assigning and reading a location
regardless.

matrix_access(-5,5) can return something which is tagged with get/set
fallbacks so that both:

> a = matrix_access(-5,5)

and

> matrix_access = a

work.




-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net