3 ms·
Got it now, thanks. But, this (the "return common();") could be done even if the function "common" was not nested within the current function, but defined outsi
by vram22 9y ago
Got it now, thanks. But, this (the "return common();") could be done even if the function "common" was not nested within the current function, but defined outside of it, right? So what is the benefit of defining "common" as a nested function? Is it because it then has access to, and can use, variables defined in the outer function?
- WalterBright 9y agoYes, you can do it that way. But then you'll need a "context pointer" to pass references to the locals it'll need, and the function will need to be located "someplace else", meaning it is not encapsulated. I've done that for years with C and C++. Nested functions are so much nicer and clearer.
- vram22 9y agoGot it now, thanks. I've used nested functions in Python and they have some good uses. Will check them out in D.