On Sun, 2009-03-22 at 15:27 +0000, pancake wrote:
> 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.
On this point:

Getting parallel is more related to loops than to operators. 

A family of [OpenMP (... = ...)] implementing the OpenMP specification
would be sufficient for implicit parallelism.

OpenMPI(and its predecessors - lam/mpich) are not designed for automatic
parallelism; they are for explicit parallelism.

> 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 flexible in writing, but unreadable for the reader. To
understand string str = obj, the reader has to find the definition of
Object, search for all autocast annotations, then guess which is which.

> 
> 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.
> 
The more complex the situation gets, the more difficult for the reader
to understand the code. Verbosity is not always bad, given that our
brains are not compilers.

Does java support operator overriding? Python? C#?

Yu
> 
> 
> --pancake
> _______________________________________________
> Vala-list mailing list
> Vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to