-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promote different types to dynamic? #98
Comments
It seems like the appropriate thing to do would be return |
Won't that defeat the idea of promoting to a common type? |
The difference in type here is more of an implementation detail. If we could have |
Perhaps we need a specialized promotion approach similar to Unitful.jl |
julia> struct A{T}
x :: T
y :: T
end
julia> A(x...) = A(promote(x...)...)
A
julia> A(1,1)
A{Int64}(1, 1)
julia> A(1.0,2)
A{Float64}(1.0, 2.0) Would be nice to have this accept static arguments as well, even if the result isn't static. |
I think we should generally respect the interfaces of methods like julia> convert(StaticInt{4}, 2)
ERROR: TypeError: in typeassert, expected StaticInt{4}, got a value of type StaticInt{2}
Stacktrace:
[1] convert(#unused#::Type{StaticInt{4}}, x::Int64)
@ Base ./number.jl:7
[2] top-level scope
@ REPL[4]:1 And I'd be on board with |
I understand the logic behind using promote this way but I still don't think this is what the original intention behind promote was. It was to make it easier to pass mismatched types to things like I just want to make sure we aren't changing this behavior just for a quick fix |
Perhaps these should return
Int
s?The text was updated successfully, but these errors were encountered: