# 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:** 10

<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, 12:41pm UTC](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824/10 "2024-09-25T12:41:54Z")

</div>

> [@Ronneesley](#):
>
> At module `B` I should define one by one function

You could define a single function, e.g.

```julia
insert_process_request(r::Request, T::Type) =
       insert_process_request_highorder(r, request_string[T], 
         get_post_data_user, connect_with_db_module_B, 
         process_user_request, close_db_connection_module_B!)

```

where `request_string` is a dictionary mapping request types to strings.

(You could also use other abstractions. If you really want to dispatch on the request types, then the request types could be singleton instances of subtypes of an `AbstractRequestType`, with a method `request_string(request_type)` that returns the string.)

---

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