I see thank you very much for your answer! :D
El martes, 25 de octubre de 2016, 13:20:50 (UTC-5), Tim Holy escribió:
>
> > Why not use dispatch instead?
>
> Because subtyping isn't powerful enough for all needs. For example:
>
>
> julia> using Unitful
>
> julia> const mm = u"mm"
> mm
>
> julia> is
> Why not use dispatch instead?
Because subtyping isn't powerful enough for all needs. For example:
julia> using Unitful
julia> const mm = u"mm"
mm
julia> isa(3.2mm, AbstractFloat)
false
You'd probably like to use the fancy logic of `FloatRange` if you're
constructing a range `3.2mm:0.1mm:4.
Why not use dispatch instead?
isexact(::Integer) = true
isexact(::Rational) = true
isexact(x::Complex) = isexact(x.re)
isexact(::Any) = false
+1. We need number traits for a variety of circumstances; I was also
contemplating them as a step in generalizing the FloatRange/StepRange
distinction, for example to Unitful numbers (numbers with physical units).
You need type-stability for the created range object, so I think a trait is
the only
for values, something like this may do:
function isexact(x)
if isa(x, Integer) || isa(x, Rational)
true
elseif isa(x, Complex)
isExact(x.re)
else
false
end
end
On Monday, October 24, 2016 at 2:09:09 PM UTC-4, jw3126 wrote:
>
> A couple of times I was in