Is it possible to have user defined implicit conversion in Julia?

This is an example of how I imagine it should work:

type MyNum
x
end

implicit_convert(::Type(Float64), a::MyNum) = convert(Float64, a.x)

f(x::Float64) = 2.
f(MyNum(1.))   # error, sadly

In C++ this behaviour can be obtained overloading 

PS I don’t want to use inheritance
​

Reply via email to