D's nested functions (like Pascal's) have two frame pointers - a dynamic frame pointer (like C has), pointing to the caller's stack frame, and a static frame pointer pointing to the enclosing function's stack frame.
This allows the nested function to access the enclosing function's variables.
The original pascal based Mac toolbox APIs encouraged nested procedures in modal contexts - but Nested procedures couldn’t escape their outer frame.