Is there any possibility to define own methods? Example: if I multiply two vectors there are three possibilities: dot product, cross product, and a simple scale. For the cross product it is OK to use .__mul or the * operator. But for the dot product it would be nice having the possibility to define an own parameter, say .* Is this doable? Andrew has used in his Vec3 class the concatenated operaton or the … Operator, but maybe there is another way. I was thinking of writing a more general class for vector and matrix operations, and here such methods would be highly welcome. Same is for a ./ operator, for example.
You can’t define your own operator syntax. I actually think overloaded operators are not that nice when they are taken to the extreme. It gets confusing and the meaning isn’t obvious unless you know the special syntax.
To me it is much clearer to see:
v = v1:cross( v2 ) d = v1:dot(v2)
v = v1 * v2 d = v1 .. v2
Ok, many thanks for your answer. You are correct, it is much easier to read the text described operation. I just thought that the .* operator is used in several math programs already, so that we can implement that feature also in Codea. But it is definitely not a problem.