I am still trying to figure out why Pascal had nested procedure/function definitions. It was pretty weird to define a function only visible inside the current function/procedure, that you are only going to call one time, in most cases, during the run of the outer procedure/function. Some kind of Lambda expression would probably have made more sense.
, which isn't the end of the world. There are advantages of nesting as well, like avoiding global variables or namespace pollution. See Nested_functionw
, and this post: Re: Nesting functions- Why?
Either way, nested functions in an object-oriented language aren't really needed, and most modern dialects of Pascal (Delphi, Freepascal, GNUPascal) have object capabilities built-in, so the point is a little more moot now.