# pass a funtion(with function signature) as an argument

**URL:** https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744
**Category:** New to Julia
**Created:** [May 1, 2019, 6:32pm UTC](https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744 "2019-05-01T18:32:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![FrankCimballi](https://avatars.discourse-cdn.com/v4/letter/f/4af34b/32.png) [@FrankCimballi](https://discourse.julialang.org/u/FrankCimballi)
#### Post date: [May 1, 2019, 6:32pm UTC](https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744/1 "2019-05-01T18:32:11Z")

</div>

how do i pass a function as an argument while specifying the function signature? What would be the syntax for something like this?

function foo(a::Any, goo:: **Function{Any, Int64}** )  
return goo(a, 10)  
end

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [May 1, 2019, 6:38pm UTC](https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744/2 "2019-05-01T18:38:50Z")

</div>

You can’t. You can only pass generic functions which can have several methods. However, the call `goo(a, 10)` will pick the appropriate method of `goo` (or error if there is none). So you should be ok.

Jeff’s thesis is a good read: [phdthesis/main.pdf at master · JeffBezanson/phdthesis · GitHub](https://github.com/JeffBezanson/phdthesis/blob/master/main.pdf).

PS: check out [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) and welcome!

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [May 1, 2019, 6:50pm UTC](https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744/3 "2019-05-01T18:50:41Z")

</div>

You can create a new parametric type that hold the input/output types as parameters. You can check that [gist](https://gist.github.com/jonathanBieler/41da202b1d3e914e803cd79c83ac3ed9) that I made a while ago for a similar question for an example of that (the function `g` at the end show how you can constrain on input/ouput parameters types).

---

<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: [May 1, 2019, 9:13pm UTC](https://discourse.julialang.org/t/pass-a-funtion-with-function-signature-as-an-argument/23744/4 "2019-05-01T21:13:02Z")

</div>

> [@FrankCimballi](#):
>
> how do i pass a function as an argument while specifying the function signature?

Note that there would generally be no performance benefit to doing this — Julia’s compiler already specializes a function to the passed argument types when it is called, including higher-order (function) arguments.
