# Create dynamic functions with Macro

**URL:** <https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824>\
**Category:** General Usage\
**Tags:** macros, metaprogramming\
**Created:** [September 24, 2024, 5:48pm UTC](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824 "2024-09-24T17:48:42Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [September 25, 2024, 4:41pm UTC](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824/14 "2024-09-25T16:41:24Z")

</div>

> [@Ronneesley](#):
>
> I saw your answer… looks good, no so beatiful because I fear the “explosion” of functions passed as argument.

If you have an explosion of arguments, it’s probably a sign that you need better abstractions.

Abstraction and software design and refactoring is hard, and I can’t give you a magic formula in a few words that will solve everything — there are whole books written about this. But using macros to automate cut-and-paste code is a last resort, rarely needed for this purpose, and certainly not the first thing you should reach for.

One reason is that macros have to be designed very carefully to avoid subtle fragilities arising from scope. Another is that macros usually have less information to work with than ordinary functions — macros only know how things are “spelled”, whereas functions know types and values. See also the thread: [How to warn new users away from metaprogramming](https://discourse.julialang.org/t/how-to-warn-new-users-away-from-metaprogramming/35022)

---

_[View the full topic](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824)._
