# The zero-argument anonymous function name

**URL:** https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025
**Category:** General Usage
**Created:** [May 31, 2017, 10:58pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025 "2017-05-31T22:58:44Z")
**Posts on this page:** 8
**Page:** 2

<div class="post-metadata">

### Author: ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)
#### Post date: [June 1, 2017, 5:57pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/23 "2017-06-01T17:57:52Z")

</div>

I had read it a while ago, had forgotten about it, thanks. So could you say the splat is defined by `bar(a,b,x...)`, where `b` must bind to the first element of the tuple `(2,3,4)`, where `b` can’t accept a splice, only one element?

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [June 1, 2017, 5:58pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/24 "2017-06-01T17:58:09Z")

</div>

> [@hpoit](#):
>
> How have you used it?

Forward arguments, call functions when I have arguments in a tuple, etc.

> [@hpoit](#):
>
> where b must be assigned to something. Is that a correct interpretation?

No.

Note that the `f(a...)` function call syntax is totally unrelated to the `f(a...)` function definition syntax. A function takes a list of positional argument, it doesn’t matter semantically **AT ALL** how you pass it and how the callee want to use it. Function calls are not pattern matching and you should stop thinking the x in `bar(1, x...)` has anything to do with the `x` in `bar(a, b, x...)`.

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [June 1, 2017, 6:00pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/25 "2017-06-01T18:00:34Z")

</div>

And afaict splice means inserting one list to another to create a bigger one. `(a, b..., x)` is splicing `b` into a tuple. There’s no object/variable that is called a “splice” anywhere in this thread. The variable length argument are passed in as a tuple. As I mentioned in the [very first reply](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/2)

---

<div class="post-metadata">

### Author: ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)
#### Post date: [June 1, 2017, 6:30pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/26 "2017-06-01T18:30:54Z")

</div>

```julia
julia> bar(a,b,x...) = (a,b,x)
bar (generic function with 1 method)

julia> x=(7,8,9)
(7,8,9)

julia> bar(1,x...)
(1,7,(8,9)) # take 1, take 7 for b, take what's left of x

julia> bar(x...)
(7,8,(9,)) # take first element of x for a, second element of x for b, 
# and take rest of x for ...

```

Is this reading correct? If not, can you read it to me?

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [June 1, 2017, 6:39pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/27 "2017-06-01T18:39:53Z")

</div>

> [@hpoit](#):
>
> Is this reading correct? If not, can you read it to me?

No.

For `bar(1, x...)` it reads. constructing argument list from `(1, x...)` as `(1, 7, 8, 9)`; take first as `a = 1`, take second as `b = 7`, take the rest as `x=(8, 9)`.

For `bar(x...)` it reads. constructing argument list from `(x...)` as `(7, 8, 9)`; take first as `a = 7`, take second as `b = 8`, take the rest as `x=(9,)`.

---

<div class="post-metadata">

### Author: ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)
#### Post date: [June 1, 2017, 10:13pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/28 "2017-06-01T22:13:50Z")

</div>

```julia
julia> bar(a,b,x...) = (a,b,x)
bar (generic function with 1 method)

julia> x = (7,8,9)
(7,8,9)

julia> bar(x...)
(7,8,(9,))

julia> x = [1,2,3,4]
4-element Array{Int64,1}:
 1
 2
 3
 4

julia> bar(x...)
(1,2,(3,4)) # why not (1,2,(3,4,))?

```

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [June 1, 2017, 10:52pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/29 "2017-06-01T22:52:24Z")

</div>

> [@hpoit](#):
>
> why not (1,2,(3,4,))?

They are the same. We also don’t print `5` as `(5)` or `((((((((5))))))))` even though they are the same.

---

<div class="post-metadata">

### Author: ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)
#### Post date: [June 1, 2017, 11:28pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025/30 "2017-06-01T23:28:52Z")

</div>

Oh Michael had explained that before, I’m sorry. `(9,)` has a comma to differ it from `()`, since `(9)` would be the same as 9. Thanks Yichao.

[Previous page](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025.md?page=1)
