Open
Description
Hi there,
I would like to suggest new language features, namely more operator overloading. It would be nice to be able to overload [] and () operators to create array-like access to data structures and functors. Examples:
package First
class MyList<T>
// Some stuff
function operator[](int index) returns T
return getEntry(index).elem
class MyFunctor
private real memory = 0.0
function operator()(real r1, real r2) returns real
memory += r1*r2
return memory // Just an example
init
// Usage operator[]
MyList<int> list = new MyList<int>()
print(list[0].toString())
// Usage operator()
MyFunctor func = new MyFunctor()
print(func(2.0, 3.0).toString()) // Displays 6
print(func(2.0, 3.0).toString()) // Displays 12
print(func(2.0, 3.0).toString()) // Displays 18
endpackage
And keep the good work :)