I was trying to implement my own add function for my own data types but that seems to deliver errors that I can’t find the reason for. Just look at this example
type mine x :: Int8 z :: Float64 mine() = new() end function ++(U::mine, V::mine) w = mine() w.x = U.x + V.x w.z = U.z + V.z return w end; # define two instances of mine() u = mine() u.x = 1 u.z = 3.1416 v = mine() v.x = 2 v.z = 2.7183 # add them up u ++ v > mine(3,5.8599) # We succeeded :) # Now with standard + instead of ++ # It's the exact same code with ++ replaced with + ! function +(U::mine, V::mine) w = mine() w.x = U.x + V.x w.z = U.z + V.z return w end;
LoadError: error in method definition: function Base.+ must be explicitly imported to be extended
while loading In, in expression starting on line 1
…so adding a (working) new method for + yields an error and it can’t be used.
So what am I doing wrong? Any help will be greatly appreciated