Some questions about function of function

I am not so familiar to Julia.
I have a program as follows, it means function t2 is a parameter of t5.
My question is that why it needs (args...; kwargs...) -> begin in beginning of t5 , and why here is ;, if it is (args..., kwargs...) -> begin ,there will be erros.
Thanks for your help.

function t5(t2, x,y)
    (args...; kwargs...) -> begin
        return t2(args..., kwargs...)+x+y
    end
end

function t2(theta,gamma)
    return theta*gamma
end

t5(t2, 3, 4)(2,5)

In Julia, functions get both positional arguments and keyword arguments. When defining a function, the positional arguments are defined first and then a semicolon ; separates them from the keyword arguments declaration.

When calling functions, the same convention is used, except the ; can be replaced with a ,. Probably for backward compatibility reasons, and possibly to make calls look nicer. When using the splat (...) operator for kwargs this is no longer optional, as Julia will interpret the expanded kwargs as positional parameters with no ;.

Therefore, in the example shown,

should be written as

return t2(args...; kwargs...)+x+y

The Julia docs do a good job at describing these notions. The relevant link is:
https://docs.julialang.org/en/v1/manual/functions/#Keyword-Arguments

4 Likes

OK, thank you very much, Dan.
I understand some of this knowledge,and I will continue to study for good use of them.