Il giorno martedì 15 marzo 2016 11:51:31 UTC+1, Carlo Lucibello ha scritto:
>
> 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 
>
*  overloading operator double() 

> PS I don’t want to use inheritance
> ​
>

Reply via email to