JuliaGraphics / ColorTypes.jl

Basic color definitions and traits
Other
78 stars 36 forks source link

replace use of deprecated _parameter_upper_bound function #289

Open vtjnash opened 1 year ago

vtjnash commented 1 year ago

_parameter_upper_bound makes an awkward API, since it constrains the subtypes into preserving the parameter order of the supertype (no ability to add earlier parameters or drop unnecessary ones), and thus was removed from elsewhere for that reason. At the time, there really was not a suggested replacement. Upon reflection recently, I believe a mild improvement may be to use fieldtype. Calling fieldtype(t, 1) or fieldtype(t, :name) connects the type computation to some specific value in memory / usage, and it is well supported by the compiler (as it is an essential part of calling constructors).

https://github.com/JuliaGraphics/ColorTypes.jl/blob/6cbe7ab6ef11e28df0812bf4eafc3580b26f792b/src/traits.jl#L140-L142 c.f. https://github.com/JuliaLang/Compat.jl/pull/671/files#r1133153916 c.f. https://github.com/JuliaML/LossFunctions.jl/pull/153/files#diff-3ff7c6506d0aaafc6b13476d1c95b2afeec48f2fa3f2117c0327a3f08db66a70R22-R23