The zero-argument anonymous function name

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?

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

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...).

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

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?

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,).

2 Likes
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,))?

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

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.