Is nested function efficient? : <p>In programming languages like Scala or Lua, we can define nested functions such as</p>

<pre><code>function factorial(n)
  function _fac(n, acc)
    if n == 0 then
      return acc
    else
      return _fac(n-1, acc * n)
    end
  end

  return _fac(n, 1)
end
</code></pre>

<p>Does this approach cause any inefficiency because the nested function instance is defined, or created, everytime we invoke the outer function?</p>
