# Never done metaprogramming and now I am thinking I have the perfect use case for i

**URL:** <https://discourse.julialang.org/t/never-done-metaprogramming-and-now-i-am-thinking-i-have-the-perfect-use-case-for-i/56367>\
**Category:** General Usage\
**Created:** [March 2, 2021, 9:34pm UTC](https://discourse.julialang.org/t/never-done-metaprogramming-and-now-i-am-thinking-i-have-the-perfect-use-case-for-i/56367 "2021-03-02T21:34:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [March 2, 2021, 9:34pm UTC](https://discourse.julialang.org/t/never-done-metaprogramming-and-now-i-am-thinking-i-have-the-perfect-use-case-for-i/56367/1 "2021-03-02T21:34:15Z")

</div>

Never done metaprogramming and now I am thinking I have the perfect use case for it. I have code that looks like the following and it’s quite tedious:

```julia
    if params.scr_start &gt; 0 
        cbset = CallbackSet(cb_screen)
    end
    if params.npi_start &gt; 0 
        cbset = CallbackSet(cb_npi) 
    end 
    if params.scr_start &gt; 0 &amp;&amp; params.npi_start &gt; 0 
        cbset = CallbackSet(cb_npi, cb_screen)
    end
    # ... some other combinations 

```

is there a way that a macro would help me out? Something like `@cbset params.scr_start params.npi_start` which can then generate the proper variable for me?

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1614720834230400?thread_ts=1614720834.230400&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [March 3, 2021, 12:24am UTC](https://discourse.julialang.org/t/never-done-metaprogramming-and-now-i-am-thinking-i-have-the-perfect-use-case-for-i/56367/2 "2021-03-03T00:24:02Z")

</div>

Any drawback to using something like this?

```julia
cbset = CallbackSet([cb_scr, cb_npi][[params.scr_start, params.npi_start] .> 0]...)

```

Or similar using `filter()`.
