You could output
code_lowered(f), i.e. the code for the first method of
f (likely the only method if
f is an anonymous function). e.g.
Base.show(io::IO, x::mytype) = print(io, "mytype: ", code_lowered(x.f))
function Base.show(io::IO, m::MIME"text/plain", x::mytype)
show(io, m, code_lowered(x.f))
Here, I wrote distinct 2- and 3-argument
show functions because only in the 3-argument (multiline) case does
code_lowered(x.f) show the actual lowered code.
(As far as I know, the non-lowered code, i.e. the user’s exact input, is not actually saved unless you do something like the macro trick suggested in another post.)
show should not call
display does not take an