-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
similar and traits #18161
Comments
This seems good! While we are thinking about this I would also love to see some solutions for arrays of fixed size (the compiler might need to know the sizes as constants, e.g. as |
Also it would be good to start thinking about adding something like Having something like this would be very helpful for some packages. (JuliaDiff/ForwardDiff.jl#143, SimonDanisch/FixedSizeArrays.jl#118) In practice |
+1 for I've also been thinking that more traits would be really useful for dispatch on array types. Many functions assume, e.g., mutability, while you might want separate methods for arrays of fixed size and other traits. |
These would all be new signatures, so this could even be added post 1.0. In the meantime, this is unlikely to undergo a massive overhaul in the next few months. |
How about requiring that any |
Ref. JuliaLang/LinearAlgebra.jl#271 (regarding |
Ref. #10889 (regarding traits to characterize storage). |
Ref. #11573 (regarding a formal interface/contract for |
Ref. #10064 (regarding a formal interface/contract |
Ref. #12441 (regarding a formal interface/contract for |
Ref. #11610 (regarding the interplay between |
Ref. JuliaLang/LinearAlgebra.jl#370 (regarding |
Ref. #15198 (regarding |
Ref. #24019 (regarding |
Another use case appeared at JuliaData/DataFrames.jl#1257: for a |
Ref. #22218 (regarding |
We do have some of these (e.g., #18161 (comment)), and they are documented: julia> similar(Array{Float16}, (2, 2))
2×2 Array{Float16,2}:
1.0e-7 0.0
0.0 0.0 |
Right. I suggest we document this as part of the |
I know this is an old issue, but I'd like to echo the interest in having Case in point: I have a package which has its own implementation of |
The situation for the
similar
function feels a little messy these days (perhaps I'm wrong about that and it's all under control, in which case, consider this a documentation request). It seems like thesimilar
API could be clarified with appropriate traits, e.g.This is sort of already what we're doing but the current system is a bit more ad hoc: type arguments are treated as an implicit element type trait and a tuple of integers is treated collectively as a dimensions trait. It might be fruitful to have a more explicit trait-based core API and translate the various shorthands into that.
The text was updated successfully, but these errors were encountered: