# Unpacking of variables that do not exist

**URL:** <https://discourse.julialang.org/t/unpacking-of-variables-that-do-not-exist/105575>\
**Category:** General Usage\
**Tags:** macros, modelingtoolkit, catalyst\
**Created:** [October 30, 2023, 3:09pm UTC](https://discourse.julialang.org/t/unpacking-of-variables-that-do-not-exist/105575 "2023-10-30T15:09:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [October 30, 2023, 3:23pm UTC](https://discourse.julialang.org/t/unpacking-of-variables-that-do-not-exist/105575/2 "2023-10-30T15:23:12Z")

</div>

> [@johannesnauta](#):
>
> I obviously get the error that the variable `μ` does not exist; as expected. However, is it possible to “conditionally” `@unpack`? As in, can I create a macro/function to do something like:
> 
> ```julia
> julia> @unpack_conditionally η, μ = reaction_system; η
> 
> ```

Assuming `reaction_system` is a named tuple, you can `merge` it with another named tuple to provide defaults for some parameters. For example:

```julia
julia> params1 = (a=3, b=4)
(a = 3, b = 4)

julia> (; a, b) = merge((a=0,), params1) # default a=0 is ignored
(a = 3, b = 4)

julia> params2 = (b=4,) # missing a
(b = 4,)

julia> (; a, b) = merge((a=0,), params2) # default a=0 is used
(a = 0, b = 4)

```

(Here, I’m using the built-in [property-destructuring syntax](https://docs.julialang.org/en/v1/manual/functions/#Property-destructuring) rather than `@unpack` from [UnPack.jl](https://github.com/mauro3/UnPack.jl).)

---

_[View the full topic](https://discourse.julialang.org/t/unpacking-of-variables-that-do-not-exist/105575)._
