# Forwarding & invoking a block of code

**URL:** https://discourse.julialang.org/t/forwarding-invoking-a-block-of-code/69185
**Category:** New to Julia
**Created:** [October 4, 2021, 11:53am UTC](https://discourse.julialang.org/t/forwarding-invoking-a-block-of-code/69185 "2021-10-04T11:53:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![whatsthecraic](https://avatars.discourse-cdn.com/v4/letter/w/7bcc69/32.png) [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)
#### Post date: [October 4, 2021, 11:53am UTC](https://discourse.julialang.org/t/forwarding-invoking-a-block-of-code/69185/1 "2021-10-04T11:53:18Z")

</div>

I’m writing a wrapper function for a macro, that can be invoked, for instance as `@snoopl "/tmp/a.txt" "/tmp/b.txt" println("Helloworld")`. Now when trying to wrap it, it fails with the error `ERROR: UndefVarError: code_block not defined`, which I imagine it means it is interpreting the argument code\_block literally, as a symbol (see below). What’s the correct way to define it, and then to invoke it with an arbitrary code block?

```julia
function compile_time(code_block)
    a = "/tmp/a.txt"
    b = "/tmp/b.txt"
    @snoopl a b code_block
end

```

Source code: [https://github.com/timholy/SnoopCompile.jl/blob/master/SnoopCompileCore/src/snoopl.jl](https://github.com/timholy/SnoopCompile.jl/blob/master/SnoopCompileCore/src/snoopl.jl)

---

<div class="post-metadata">

### Author: ![whatsthecraic](https://avatars.discourse-cdn.com/v4/letter/w/7bcc69/32.png) [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)
#### Post date: [October 4, 2021, 1:44pm UTC](https://discourse.julialang.org/t/forwarding-invoking-a-block-of-code/69185/2 "2021-10-04T13:44:01Z")

</div>

I think I’ve managed to move forward by:

```julia
macro compile_times(code_block)
quote
    root = Base.Filesystem.tempname()
    path_func_names = "$(root)_functions.txt"
    path_llvm_timings = "$(root)_llvm.txt"
    println("Function names: $(path_func_names), llvm timings: $(path_llvm_timings)")
    @snoopl path_func_names path_llvm_timings $code_block
    times, _ = SnoopCompile.read_snoopl(path_func_names, path_llvm_timings)
    return times
end
end

```

here the macro @macroexpand has been fundamental to debug the code. I still don’t really understand the differences between quote, esc and QuoteNode though?
