Feature Request:Overloaded Operators.

BlitzMax Forums/BlitzMax Programming/Feature Request:Overloaded Operators.

errno!(Posted 2006) [#1]
With the advent of Max3D, I see a great need for overloaded operators for all our 3D Math classes and such we'll no doubt be writing for our games and applications. Every game needs one, be it simple vector classes or a matrix class.

An example of how this could be implemented in Max would be,


Type TVector

         Field X#,Y#,Z#

        method [+](with:TVector)
                     X:+with.x
                     Y:+with.y
                     Z:+with.z
        end Method

        method [*](with:TVector)
                 z:*with.x
                'etc
        End method

End Type



But the key is you are allowed to do multiple operators based on the right side of the operation. So if a coder wishes to multiply a vector by a single float(A Valid request) the right operator could be invoked.

Please make this happen.


ozak(Posted 2006) [#2]
I'm an old game programmer that's recently switched from game development in C/C++ to doing commercial 3D work in Java.
And you really don't miss operator overloading once you don't have it. Actually it makes the code a lot clearer. (I.e. myVector.plus(someOtherVector), myVector.plusEquals(someOtherVector) etc.)


H&K(Posted 2006) [#3]
Although it does seem a pain at first to have to explicitly name all your, (For example Add), functions. In the long run it makes errors less likely because you have to then explicitly choose which one to use, so no accedntly adding The wrong things to each other by lacks syntax


Dreamora(Posted 2006) [#4]
Pointless.
We don't even have regular overloading, which is definitely more needed ...


H&K(Posted 2006) [#5]
I think the same reasoning can apply to both.
I would like Regular overloading, dont get me wrong. But all it means by not having it, is that I have to think of different names for each function

Method AddIntIntBiPairIntFloat etc..