home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!umn.edu!csus.edu!netcom.com!erc
- From: erc@netcom.com (Eric Smith)
- Newsgroups: comp.lang.c++
- Subject: Re: Why not nested functions ?
- Keywords: nested functions, c++
- Message-ID: <1992Dec16.232309.12886@netcom.com>
- Date: 16 Dec 92 23:23:09 GMT
- References: <KRISS.92Dec16162433@blues.ibp.fr>
- Distribution: comp
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- Lines: 26
-
- In article <KRISS.92Dec16162433@blues.ibp.fr> grosjean@masi.ibp.fr writes:
- >My point is that you can *simulate* nested functions using
- >a local class. To call the function you call a member function
- >of the local class, you explicitely give the syntaxic context
- >you need for the function copying the automatic variables
- >you want to use in local class members variables.
- >
- >In one word : I *do* it, so it can be done.
-
-
- The most important feature of a nested function is that you can call
- it from an unrelated function, which has no knowledge of its context.
-
- I don't see how this can be simulated without adding it as a feature
- to the language, but I don't see any real reason for not adding that
- feature. It sure seems like it would make C++ a much more powerful
- language, and that a lot of the most complicated code would be neater
- and easier to work with. It also doesn't seem very hard to implement,
- using pointers to stack frame descriptors or something like that.
-
- Or is there a way to simulate this feature using objects? If so, can
- someone please explain it clearly or refer us to a clear explanation?
- The original poster seems to be describing a way to simulate a very
- limited subset of this feature, in which it is necessary for all
- functions invoking the nested function to have access to its context,
- which sacrifices the biggest advantage of nested functions.
-