Are there any programming languages where you can define functions within other functions? I think it'd be useful - in situations like this:
function X is used, and only used, within function A. X is really just a part of A that has been broken away to better structure the code.
If you defined X within A -- like at the start or end of it -- this would make the structure of the code more explicit. When you came across X you'd know straight away, and for certain, that A was the only place it was used.
The motivation for this is pretty similar to that of defining functions within objects or within modules.