julia> function main()
todB(x) = 10*log10(x)
println("100x is $(todB(100)) dB.")
end
main (generic function with 1 method)
julia> CodeTracking.definition(String, @which main())
(" todB(x) = 10*log10(x)", 2)
Which is just the closure defined inside the method that we are querying the body for.
If we add something before the closure:
julia> function main()
foo
todB(x) = 10*log10(x)
println("100x is $(todB(100)) dB.")
end
main (generic function with 1 method)
julia> CodeTracking.definition(String, @which main())
("function main()\n foo\n todB(x) = 10*log10(x)\n println(\"100x is \$(todB(100)) dB.\")\nend", 1)
Then we get the full body of the method we want.