# Please explain fine point of splatting syntax in macros

**URL:** <https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 14, 2018, 8:33am UTC](https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303 "2018-10-14T08:33:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 14, 2018, 8:33am UTC](https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303/1 "2018-10-14T08:33:10Z")

</div>

[This line](https://github.com/JuliaLang/julia/blob/7d0edd82ef63183844b30a36d1cd4573c2fbb47c/base/namedtuple.jl#L232) in `base/namedtuples.jl` looks like

```julia
:( NamedTuple{$names,$types}(($(vals...),)) )

```

and I am asking about the

```julia
($(vals...),)

```

part. The `,` and the outer `()`s seemed redundant to me, but if I omit them, the expansion does not work. What am I missing, what’s their role here?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [October 14, 2018, 9:44am UTC](https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303/2 "2018-10-14T09:44:02Z")

</div>

Isn’t the comma just used to indicate a named tuple:

```julia
julia-1.0> x = (a = 1,)
(a = 1,)

julia-1.0> x = (a = 1)
1

```

(I’m still working out how these named tuples operate myself…)

---

<div class="post-metadata">

**Author:** ![Liso](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Liso](https://discourse.julialang.org/u/Liso)\
**Post date:** [October 14, 2018, 11:55am UTC](https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303/3 "2018-10-14T11:55:34Z")

</div>

Not only named tuples but distinguish any tuples from expression in parenthesis (if there is one element).

```julia
julia> (1)
1                                                                                 
                                                                                  
julia> (1,)
(1,)   

```

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 14, 2018, 6:08pm UTC](https://discourse.julialang.org/t/please-explain-fine-point-of-splatting-syntax-in-macros/16303/4 "2018-10-14T18:08:21Z")

</div>

> [@Tamas\_Papp](#):
>
> `:(($(vals...),))`

This would generate an arbitrary length `Tuple` inside an `Expr` objtect from an array of values of any length.

```Julia
julia> :(($([1,2,3]...),))
:((1, 2, 3))

julia> :($(Tuple([1,2,3])))
(1, 2, 3)

```

Apparently, if you do it differently, then it is converted into a `Tuple` not wrapped in `Expr` object…
