Cant push! JuliaInterpreter.compiled_methods

How can I add a function to JuliaInterpreter.compiled_methods?

function println_(x)
  println(x)
end

push!(JuliaInterpreter.compiled_methods,println_)

----> MethodError: Cannot convert an object of type typeof(println_) to an object of type Method

As the name indicates, you should push methods, not functions. This works:

julia> using JuliaInterpreter

julia> function println_(x)
           println(x)
       end;

julia> m = which(println_, (Any,))
println_(x) in Main at REPL[2]:2

julia> push!(JuliaInterpreter.compiled_methods, m)

See also PSA: how to quote code with backticks

2 Likes

Does work! Thx