Is there a reason why one cannot specialize the global function k
within the scope of another function? This is on Julia 0.6.3.
k(a, b) = a + b
function doesnotwork(B)
k(a) = k(a, B)
k(1)
end
function doeswork(B)
f(a) = k(a, B)
f(1)
end
function doeswork2(B)
g(a, b) = a + b
g(a) = g(a, B)
g(1)
end
The error is
julia> doesnotwork(1)
ERROR: MethodError: no method matching (::#k#1{Int64})(::Int64, ::Int64)
Closest candidates are:
k(::Any) ...
so it looks like the global k
is masked by the local one.