Operator Overloading?

BlitzMax Forums/BlitzMax Programming/Operator Overloading?

Endive(Posted 2016) [#1]
Does Blitzmax have any facility for operator overloading or should I use functions, eg:

v3:vector3=dot(v1,v2)


Looks like operator overloading was in the bounties so I'm guessing not?


TomToad(Posted 2016) [#2]
No op overloading. You'll have to create a function instead.
No function overloading either, so you'll have to create a unique name for functions accepting different parameters, or get creative.

Function MakeColors(Red:int, Green:Int = -1, Blue:Int = -1)
    If Green = -1 then
        Blue = Red & $FF
        Green = (Red Shr 8) & $FF
        Red = (Red Shr 16) & $FF
    End If
    DoStuff()
End Function

'You can now call MakeColors with Red, Green, Blue
MakeColors($0F, $FE, $10)

'Or you can use an Int with RGB combined
MakeColors($0FFE10)