# Modifying lowered code

**URL:** <https://discourse.julialang.org/t/modifying-lowered-code/6712>\
**Category:** Internals & Design\
**Created:** [October 26, 2017, 9:50pm UTC](https://discourse.julialang.org/t/modifying-lowered-code/6712 "2017-10-26T21:50:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [October 26, 2017, 9:50pm UTC](https://discourse.julialang.org/t/modifying-lowered-code/6712/1 "2017-10-26T21:50:29Z")

</div>

My tracing package currently parses files to recover the AST behind every traced function. It works, but it’s slow. Perhaps working with lowered code would be better. I’ve read the devdocs and still have a few questions. Any help greatly appreciated!

- I can get the lowered code for `foo(::Int)` with `Base.uncompressed_ast`. How do I change `foo(::Int)`'s definition with my new lowered code? That is, what’s the correct way to write `eval(:(function foo() $new_lowered_code end))`?
- Keyword argument functions are lowered into three methods. I can trace both the `kwfunc(fun)` and `fun`, or the function with the actual code. The latter sounds simpler. Is there a function like `kwfunc` to get it?
- `f(x, a=2) = x+a` defines two methods, but I don’t want to trace both. How can I identify that the `f(x)` method is a forwarding function?
- I can get most of the functions defined in module M from `names(M, true, true)`, but if M define `Base.convert(...) = ...` without importing `convert`, it won’t be part of `names`. How can I find all such methods defined in `M`?

Thank you!
