If I create a new function f(x::Float64)
and you call it like f(1)
, it will fail with a MethodError:
julia> f(x::Float64) = x + 1.0
f (generic function with 1 method)
julia> f(1)
ERROR: MethodError: no method matching f(::Int64)
This is exactly what’s happening in your example: there’s no method for copy
that applies in your example. You might argue that (a) Julia should have a definition for all possible types or that (b) Julia should at least have definitions for “core” types like Tuple
. I’m sympathetic to (a), but the general feeling is that Julia don’t do this. I fully agree with (b) and think submitting a PR that adds copy
for Tuple
is useful. You might find the current committers disagree, but that presumably depends on them disagreeing with (b).