# Meaning of non-anonymous nested/local function

**URL:** https://discourse.julialang.org/t/meaning-of-non-anonymous-nested-local-function/90799
**Category:** General Usage
**Created:** [November 25, 2022, 11:14am UTC](https://discourse.julialang.org/t/meaning-of-non-anonymous-nested-local-function/90799 "2022-11-25T11:14:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hexaeder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexaeder/32/24403_2.png) [@hexaeder](https://discourse.julialang.org/u/hexaeder)
#### Post date: [November 25, 2022, 11:14am UTC](https://discourse.julialang.org/t/meaning-of-non-anonymous-nested-local-function/90799/1 "2022-11-25T11:14:54Z")

</div>

Consider the following function

```julia
function outer(capture)
    function foo()
        capture + 1
    end
    bar = function()
        capture + 1
    end
    baz = () -> begin
        capture + 1
    end
    ...
end

```

Afaik the definitions of `bar` and `baz` are completely equivalent in constructing an anonymous function. But what about `foo`? This syntax does create a named function. Does it make any difference to my code or the compiler which style I chose? Normally I tend to use second or third option, as it is visually different from global functions and underlines the local nature of the object.

---

<div class="post-metadata">

### Author: ![DrChainsaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drchainsaw/32/8497_2.png) [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)
#### Post date: [November 25, 2022, 5:12pm UTC](https://discourse.julialang.org/t/meaning-of-non-anonymous-nested-local-function/90799/2 "2022-11-25T17:12:41Z")

</div>

I have used the `foo` form when it was convenient to have a closure with different methods for dispatch. I do sometimes fear that terrible things will happen to me for doing so though.
