Ok. I'm reading again the Modules section of the manual. Now I understand
better the difference between import and using. Thanks.
On Apr 2, 2016 1:27 PM, "Kristoffer Carlsson" wrote:
> Because you want to overload a function from Base.
Because you want to overload a function from Base.
Thanks! But why do I need to import Base.+?
Em sexta-feira, 1 de abril de 2016 12:02:13 UTC-3, Giuseppe Ragusa escreveu:
>
> ```
> import Base.+
> type numerr
> num
> err
> end
>
> +(a::numerr, b::numerr) = numerr(a.num + b.num, sqrt(a.err^2 + b.err^2));
> +(a::Any, b::numerr) = numerr(a
```
import Base.+
type numerr
num
err
end
+(a::numerr, b::numerr) = numerr(a.num + b.num, sqrt(a.err^2 + b.err^2));
+(a::Any, b::numerr) = numerr(a + b.num, b.err);
+(a::numerr, b::Any) = numerr(a.num + b, a.err);
x = numerr(10, 1);
y = numerr(20, 2);
println(x+y)
println(2+x)