[Vala] Operator overloading



Are there any plans to implement operator overloading in Vala?

I will find them really useful because it is a really nice addition feature
for the language. Using it will allow us to wrap all the arithmetic access
to use APIs like GMP for big number operations.

Bignum b = new Bignum(3); // Bignum b = 3; (should be an alias)
b *= 99999999999999999999999;
stdout.printf("%lld\n", b);

We can also use the operator overloading to wrap access to optimize
paralelized operations to be done in a while by using external APIs
like OpemMPI or any liboil to optimize code with MMX/SSE stuff.

At the same time, by having operator overloading we can have our
own implementation for any arithmetic operation over any kind of
object which will make Vala a more flexible language and this will
open lot of possibilities in video game programming.

Another nice feature would be to add an 'auto-cast' capability using
code attributes over the class definitions to simplify the code writing
when a cast is necessary to be done. for example:

  string str = obj.to_string();

This can be simplified and defined as:

.. Object definition (or any other class) ..
[[CCode (autocast="string")]
string to_string();

So we can now do:
 Object obj = new Object();
 string str = obj;

This is a not very complex situation, but we can for example serialize
data types into xml strings in a simple way with this concepts.



--pancake



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