I've never used nested functions, but have seen references to them in several languages (as well as nested classes, which I assume are related).
- What is a nested function?
- Why?!?
- What can you do with a nested function that you cannot do any other way?
- What can you do with a nested function this is difficult or inelegant without nested functions?
I assume nested functions are simply an artifact of treating everything as an object, and if objects can contain other objects then it follows.
Do nested functions have scope (in general, I suppose languages differ on this) just as variables inside a function have scope?
Please add the language you are referencing if you're not certain that your answer is language agnostic.