Closed Roger-luo closed 4 years ago
Indeed, the current dispatch implementation of the new fake subtype is only very basic, since I have not used the feature much myself yet and neither has @cscherrer yet
More info can be found in https://github.com/chakravala/Reduce.jl/issues/22#issuecomment-480909198 where I explained the Reduce.init_subtype
method
function init_subtype(name)
Expr(:block,[:(Base.$i(r::$name...)=$i(RExpr.(r)...)|>$name) for i ∈ [alg;iops]]...) |> eval
Expr(:block,[:($i(r::$name...)=$i(RExpr.(r)...)|>$name) for i ∈ [calculus;cnan;cmat]]...) |> eval
Expr(:block,[:(Base.$i(r::$name)=$i(RExpr(r))|>$name) for i ∈ [sbas;[:length]]]...) |> eval
Expr(:block,[:($i(r::$name)=$i(RExpr(r))|>$name) for i ∈ [sfun;snan;snum;scom;sint;sran;smat]]...) |> eval
end
As you can see, the new subtype name
has various new methods created for dispatch.
However, when I made the current version of init_subtype
I was only concerned with getting the largest subset of functionality working and did not focus on checking every specialized possibility yet.
The variables alg,iops,calculus,cnan,cmat,sbas,sfun,snan,snum,scom,sint,sran,smat
contain all the method names used for the dispatch as defined in args.jl and unary.jl.
The solution for this would be to modify the Reduce.init_subtype
in rexpr.jl method and refine it.
@Roger-luo this issue has now been resolved, let me know if you find another bug
julia> Reduce.@subtype SymReal <: Real
julia> SymReal(:x) * im
0 + x*im
I'm wondering if there should be some specialization for subtypes of
Real
etc.?