How do I see what's inside a function?

I don’t actually think Julia does know what the original expression is — only the parsed (or “lowered”) version, which can be retrieved as follows:

julia> f(a, b) = a + b
f (generic function with 1 method)

julia> @code_lowered f(1, 2)
CodeInfo(
1 ─ %1 = a + b
└──      return %1
)

See also Base.uncompressed_ast(::Method) as in here.

I might be mistaken, and this might change in the future if JuliaSyntax,jl replaces the current parser, but otherwise the way to go is to put functions you want to use for longer than one sitting in a file and use @edit and @which to jump to them from the REPL.

1 Like