Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
programming, a nested function is a function which is lexically
encapsulated within another function. It can only be called by the
enclosing function or by functions directly or indirectly nested within
the same enclosing function. In other words, the scope of the nested
function is limited by the enclosing function. The nesting is
theoretically possible to any level of depth, although only a few levels
are normally used in practice. Nested functions are a form of
information hiding and are useful for dividing procedural tasks into sub
tasks which are only meaningful locally; it avoids cluttering other
parts of the program with functions, variables, etc. unrelated to those
parts. Nested functions therefore complement other structuring
possibilities such as records and objects.