基本上就是标题所说的。如果我分配
g=f
或进行 g=deepcopy(f)
,结果都是相同的:重新定义 f
将重新定义 g
。有没有办法使 g 成为 f 的独立副本?julia> function f(x) x end
f (generic function with 1 method)
julia> f(1)
1
julia> g = deepcopy(f)
f (generic function with 1 method)
julia> g(1)
1
julia> function f(x) x+1 end
f (generic function with 1 method)
julia> f(1)
2
julia> g(1)
2
f = x -> x; g = f; f = x -> x + 1
。 - phipsgabler