
"Peter Dimov" wrote
What I really want is this:
void foo( myvec& v, const myset& s, int a ) { // ...
inline bool f( int x ) { return std::abs( x ) < a && s.find( x ) != s.end(); }
v.erase( std::remove_if( v.begin(), v.end(), f ), v.end() ); }
for obvious readability reasons. This syntax also allows me to use a more descriptive name instead of f, and the consistency with ordinary function definitions will make it easier to teach. It may be somewhat easier to parse or specify, but I haven't considered this in detail.
Its interesting that you bring up the teaching issue AFAIK. Robert Rameys earlier point regarding the benefits of what seems to just be a "cool" feature to C++ is apt . Do local functions, named or unnamed really add that much to the language?. They do certainly add another layer of complexity to the parser and whats more important another layer of complexity that students will feel that they must learn and use. C++'s main problem is that it doesnt have enough standard libraries to compete with (say) Java. Two obvious ones still not on the horizon are Unicode and GUI. ( I am going to try to do something about the GUI, though there must be much greater GUI experts than me that could do a better job). A major reason given by the committee AFAICS (in GUI case) was that the committee doesnt have enough time to deal with it. Yet there seems to be adequate time to discuss the addition of more complexities to the language itself. A great language missing some essential standard libraries. Will that be C++ epitaph? bemused Andy Little