Nested Function - Purpose

Purpose

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.

In languages with nested functions, functions may normally also contain local constants, and types (in addition to local variables, parameters, and functions), encapsulated and hidden in the same nested manner. This may further enhance the code structuring possibilities.

Nested functions can also be used to terminate a nested for loop early.

Read more about this topic:  Nested Function

Famous quotes containing the word purpose:

    Satire exists for the purpose of killing the social being [for the sake of] the true individual, the real human being.
    —D.H. (David Herbert)

    Culture is the tacit agreement to let the means of subsistence disappear behind the purpose of existence. Civilization is the subordination of the latter to the former.
    Karl Kraus (1874–1936)

    ... the word “education” has an evil sound in politics; there is a pretense of education,
    when the real purpose is coercion without the use of force.
    Hannah Arendt (1906–1975)