-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Dev] Avoid generic types in struct #287
Comments
Abstract vs concrete type: |
julia> mutable struct MyType{T<:AbstractFloat}
a::T
end is better choice than julia> mutable struct MyStillAmbiguousType
a::AbstractFloat
end |
The same best practices also work for container types: julia> struct MySimpleContainer{A<:AbstractVector}
a::A
end
julia> struct MyAmbiguousContainer{T}
a::AbstractVector{T}
end |
help?> isconcretetype
search: isconcretetype
isconcretetype(T)
Determine whether type T is a concrete type, meaning it could have direct instances (values x
such that typeof(x) === T).
See also: isbits, isabstracttype, issingletontype.
Examples
≡≡≡≡≡≡≡≡
julia> isconcretetype(Complex)
false
julia> isconcretetype(Complex{Float32})
true
julia> isconcretetype(Vector{Complex})
true
julia> isconcretetype(Vector{Complex{Float32}})
true
julia> isconcretetype(Union{})
false
julia> isconcretetype(Union{Int,String})
false
|
Thanks. But our model can be constructed incrementally and it may not be so costly since it is transcribed when we solve it. But the callable type are called many times so I think this is more crucial. I am updating these types. |
See #271 (comment).
This
should be replaced by
The text was updated successfully, but these errors were encountered: