Re: [Vala] Operator overloading



William Swanson wrote:
That is not true. Imagine what would happen if Vala lost support for
operators on the built-in types like int or float. Would anybody say
Vala was "equally easy to use" when even a simple expression like
"int_a + int_b" becomes "Int.add(int_a, int_b)"? The language would be
unusable. Code like "vector_a + vector_b" really IS easier to write
and comprehend than "Vector.add(vector_a,vector_b)". The question is,
are vectors and complex numbers used often enough to offset the other
disadvantages of operator overloading?

The problems already start with vectors: You may multiply two Vectors
either with dot product or cross product. Which one will be "*"? And if
you choose one the other one will still have to be called as method. As
a reader of code I would prefer method syntax for both:

v1.dot(v2)
v1.cross(v2)


Regards,

Frederik



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