Advertisement

Whatever happened to the Nested Function?

Started by March 09, 2001 03:51 AM
4 comments, last by Xorcist 23 years, 10 months ago
Anyone use nested functions... (that is to say a function defined within another function, which inturn is local and accessable only by that function in which it was defined, wow try saying that three times fast) and if so what for? I remember doing nested functions way back when, learning scope rules in Pascal, but I hardly ever see it applied to any extent these days. I guess the entire ideal behind the nested function has been swallowed up by OOP... anyways, anyone care to comment on nested functions?
Nested functions are not allowed in C++.
Advertisement
Nested functions were cool. I used to use them all the time during my Turbo Pascal / Tasm days. Closest thing to nested function declarations now is in Java. I don''t think many languages support them any more?!
isn''t it possible to write nested classes in C++ ??

flure
Check out this article on Flipcode for a nice way of implementing local functions in C++.

Moot
Nested functions are nice for callbacks and STL function objects, but I always feel a little guilty about using them. I''m afraid it will make it difficult for someone maintaining my code to find the functions since they aren''t in the "normal" place.

This topic is closed to new replies.

Advertisement