Is there a good reason why TwicePrecision{Float64} shouldn't also be a subtype of Real?
If so, how should one specify that why want a StepRangeLen where R and S might be regular reals or a TwicePrecision version?
If you want "regular reals," use StepRangeLen(ref, step, len) directly. If you want TwicePrecision, use range(start, step=step, length=len).
TwicePrecision is an internal type designed to enable hitting the endpoints of Float64 ranges accurately. If we start turning it into more of a regular number, keep in mind we might eventually need QuadPrecision to enable precise TwicePrecision range operations. I'd rather not go down that road, personally.
My problem is that I'm trying to create struct's and functions that have types based on the types in a parameter which is a range. If the range happens to be using a TwicePrecission, I still want it to call the same version of the function as would normally be called if it were a real. I guess I could do something like
T1
That doesn't look terribly messy to me. But if you don't want to have to deal with even acknowledging the existence of TwicePrecision, you may not need to:
julia> r = 1.2:2.8:16.4
1.2:2.8:15.2
julia> eltype(r)
Float64
julia> typeof(r)
StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}
julia> supertype(typeof(r))
AbstractRange{Float64}
You might be able to write all your methods to dispatch on AbstractRange{T} where T and just use the generic interface functions first, step, last.
Most helpful comment
If you want "regular reals," use
StepRangeLen(ref, step, len)directly. If you wantTwicePrecision, userange(start, step=step, length=len).TwicePrecisionis an internal type designed to enable hitting the endpoints ofFloat64ranges accurately. If we start turning it into more of a regular number, keep in mind we might eventually needQuadPrecisionto enable preciseTwicePrecisionrange operations. I'd rather not go down that road, personally.