Nested Functions in C++

Joe Buck Joe.Buck@synopsys.COM
Sat Oct 23 00:43:00 GMT 2004


On Fri, Oct 22, 2004 at 11:35:52AM -0700, Mark Mitchell wrote:
> Steven L. Zook wrote:
> 
> >Are there plans for adding nested function support to C++?
> >  
> >
> No.
> 
> >Are there significant obstacles in the way of doing so?
> >  
> >
> Technically, it's only work.  But, the C++ maintainers (myself included) 
> will probably not be keen on accepting such a patch.  We're generally of 
> the opinion that adding extensions to C++ is a mistake, unless they go 
> through the ISO standardization process first.

I don't think it's necessary for the extensions to have completed the
ISO process all the way to official parts of the language, but at least
they should be serious proposals, with rigorous specifications, that have
been at least partway through the process (written up as proposed
extensions, have been subject to criticism and review from standards
people, etc).  In particular, problematic interaction with other language
features needs to be worked out before the extension is inflicted on
users.

Consider a feature like the new use of "auto", championed by Bjarne
himself.  There appear to be some details that have not yet been worked
out, but maybe the best way to iron out the remaining issues is to have
a trial implementation to play with.

This is the one that lets you write

func (std::multimap<std::string, std::string>& amap, std::string key) {

     auto iter_pair = amap.equal_range(key);
     ...
}

instead of

func (std::multimap<std::string, std::string>& amap, std::string key) {

     std::pair<std::multimap<std::string, std::string>::iterator,
               std::multimap<std::string, std::string>::iterator>
	  iter_pair = amap.equal_range(key);
     ...
}

I want that!  I wanted it years ago.






More information about the Gcc mailing list