# How can a macro create functions that are handled at compile time?

**URL:** https://discourse.julialang.org/t/how-can-a-macro-create-functions-that-are-handled-at-compile-time/84692
**Category:** General Usage
**Created:** [July 23, 2022, 8:14am UTC](https://discourse.julialang.org/t/how-can-a-macro-create-functions-that-are-handled-at-compile-time/84692 "2022-07-23T08:14:37Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [July 24, 2022, 12:38am UTC](https://discourse.julialang.org/t/how-can-a-macro-create-functions-that-are-handled-at-compile-time/84692/2 "2022-07-24T00:38:19Z")

</div>

> [@mongi](#):
>
> how can a one macro create multiple functions

> [@Creating multiple functions (in a different or global scope) using a one macro](https://discourse.julialang.org/t/creating-multiple-functions-in-a-different-or-global-scope-using-a-one-macro/84614/2):
>
> julia\> macro example(fprefix) exs = [quote $(Symbol(fprefix, :\_, i))() = $i end for i = 1:3] @show exs esc(Expr(:block, exs...)) end @example (macro with 1 method) julia\> @example f exs = Expr[quote #= REPL[29]:2 =# f\_1() = begin #= REPL[29]:2 =# 1 end end, quote #= REPL[29]:2 =# f\_2() = begin #= REPL[29]:2 =# 2 end end, quote #= REPL[29]:2 =# f\_3() = begin …

---

_[View the full topic](https://discourse.julialang.org/t/how-can-a-macro-create-functions-that-are-handled-at-compile-time/84692)._
