# Functions with additional parentheses

**URL:** <https://discourse.julialang.org/t/functions-with-additional-parentheses/17836>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 22, 2018, 12:35am UTC](https://discourse.julialang.org/t/functions-with-additional-parentheses/17836 "2018-11-22T00:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maj684](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@maj684](https://discourse.julialang.org/u/maj684)\
**Post date:** [November 22, 2018, 12:35am UTC](https://discourse.julialang.org/t/functions-with-additional-parentheses/17836/1 "2018-11-22T00:35:05Z")

</div>

I noticed this syntax in the [DynamicHMCExamples](https://github.com/tpapp/DynamicHMCExamples.jl/blob/master/src/example_logistic_regression.jl) package.

```julia
function (problem::LogisticRegression)(θ)
    @unpack y, X, σ = problem
    @unpack β = θ
    loglik = sum(logpdf.(Bernoulli.(logistic.(X*β)), y))
    logpri = sum(logpdf.(Ref(Normal(0, σ)), β))
    loglik + logpri
end

```

Please can someone explain what this does - I haven’t found any instances of this form of declaration elsewhere.

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [November 22, 2018, 12:47am UTC](https://discourse.julialang.org/t/functions-with-additional-parentheses/17836/2 "2018-11-22T00:47:58Z")

</div>

It is this: [Methods · The Julia Language](https://docs.julialang.org/en/v1/manual/methods/index.html#Function-like-objects-1)

> Methods are associated with types, so it is possible to make any arbitrary Julia object “callable” by adding methods to its type. (Such “callable” objects are sometimes called “functors.”)

---

<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:** [November 22, 2018, 8:28am UTC](https://discourse.julialang.org/t/functions-with-additional-parentheses/17836/3 "2018-11-22T08:28:35Z")

</div>

I should probably explain things like this in the package docs, which will eventually evolve into an introduction for programming, debugging, and optimizing your own log posteriors in Julia.

---

<div class="post-metadata">

**Author:** ![maj684](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@maj684](https://discourse.julialang.org/u/maj684)\
**Post date:** [November 23, 2018, 3:14am UTC](https://discourse.julialang.org/t/functions-with-additional-parentheses/17836/4 "2018-11-23T03:14:08Z")

</div>

> [@Tamas\_Papp](#):
>
> is in the package docs, which will eventually evolve into an introduction for programming, debugging, and optimizing your own log posteriors in Juli

Thank you both!
