# Using metaprogramming to combine multiple functions and construct a composite temporary function

**URL:** <https://discourse.julialang.org/t/using-metaprogramming-to-combine-multiple-functions-and-construct-a-composite-temporary-function/116647>\
**Category:** General Usage\
**Tags:** metaprogramming\
**Created:** [July 5, 2024, 8:16am UTC](https://discourse.julialang.org/t/using-metaprogramming-to-combine-multiple-functions-and-construct-a-composite-temporary-function/116647 "2024-07-05T08:16:42Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 5, 2024, 5:05pm UTC](https://discourse.julialang.org/t/using-metaprogramming-to-combine-multiple-functions-and-construct-a-composite-temporary-function/116647/7 "2024-07-05T17:05:20Z")

</div>

> [@chooron](#):
>
> I can identify the input and output variable names of the functions. Using this information, I want to combine these functions to construct a composite function f(x,y) that can obtain the result for z4 without inputting intermediate data.

What is the context here that is leading you towards metaprogramming (which is [often a bad idea](https://discourse.julialang.org/t/how-to-warn-new-users-away-from-metaprogramming/35022))? Why not just write something like

```julia
function f(x, y)
    z1 = f1(x, y)
    z2 = f2(z1)
    z3 = f3(z2)
    z4 = f4(z1, z3)
    z5 = f5(z1)
    return (; z1, z2, z3, z4, z5)
end

```

if that is the function composition you want? That is, why are you defining a custom function-composition representation using a `Dict` of symbols rather than using the Julia language itself?

---

_[View the full topic](https://discourse.julialang.org/t/using-metaprogramming-to-combine-multiple-functions-and-construct-a-composite-temporary-function/116647)._
