lua-users home
lua-l archive

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


On Thu, 19 Oct 2000 chris@wulfenia.com wrote:

> > Forget the unflexibility of "legacy programming languages" like 
> >maybe C or BASIC (>>yuck<<).
> > You need not to "redimensioning" anything. Just add new elements
>  
> You are right, and that's one of the reasons why I like LUA. But I 
> want to use LUA as a hassle-free "driver" for my vast collection of 
> numerical libraries written in C/C++. So I think I'll use TOLUA to 
> export my C++ matrix classes. But I'm afraid there is no way to 
> overload round brackets. Q: Do I have to use a "getter" function i.e. 
> number = mat:get(1, 1), or can I overload square brackets to give my 
> users the chance to write something like: number = mat[1, 1]?

Tag Methods should do the trick.  Have a look here.  

http://www.tecgraf.puc-rio.br/lua/manual/new/manual.html#4.8

At a guess, the ones you want to look at are gettable and function.

Jonathan.