Function definition hook?

Is it possible to hook into function definition? Whenever a new function or method is defined I want to do something with the new function.

If you have an access to the source code than you can just directly edit it. If you do not have such an access, you can use Cassette.jl to introspect and transform function body. I think, that you can’t get an access to the original text representation of the function body though, because it is compiled away.

I don’t need to change the function body itself, I’m just looking to use the function object. Can I do something like this?

Base.add_function_definition_hook!(func -> @show(func))