What are the functions defined inside other functions called?

I’ve been looking for “nested” or “inner” or “subfunction” in the manual: no hits.
Does anyone remember?

Closures is a typical name. I’m not sure if Julia has a specific one.

1 Like

Closure typically has a slightly different / more broad meaning than that, but it’s tightly related.

I’d just call it an ‘inner function’ if I don’t care if the function closes over any values or not.


“What are the functions defined inside other functions called?”



Just call them functions :wink:

closure specifically is when the function has free variables whose values come from the lexical scope.

if the inner function cannot be defined outside of the outer function, is a closure over the variables in the outer function:

function outer(x)
   a = x+1
  inner(y) = a + y #requires information only available at this scope, its a closure
  return inner(2)

but a closure is a function too


I did find “inner functions” mentioned in the PDF version of the manual (the
search in the online version is a bit hard to use). Not really defined, passing references, but the text was quite consistent in calling it inner, so inner it is.

Thanks to all who responded.

1 Like