Should Any have an identity constructor method?

nsajko
Wed, 31 Jan 2024 08:19:48 +0000
Internals & Design

Many non-concrete types have constructors, for example we have AbstractFloat(0.3) == 0.3 and Union{Int,Float64}(0.3) == 0.3. Should we also have a method like Any(x) = x? Then we would have map(Any, [3,4,5]) == map(identity, [3,4,5]).

Xref: generalize the `Number` identity constructor by nsajko · Pull Request #53130 · JuliaLang/julia · GitHub

11 posts - 4 participants