Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-04-13 23:38:58

"Peter Dimov" wrote

> Yes, local functions do add to the language. What you currently need is:
> static bool f( int x, int a, myset const & s )
> {
> return abs( x ) < a && s.find( x ) != s.end();
> }
> void foo( myvec& v, const myset& s, int a )
> {
> // ...
> v.erase(
> std::remove_if( v.begin(), v.end(),
> std::bind( f, _1, a, std::ref( s ) ) ),
> v.end()
> );
> }
> As you can see, there is an additional bind needed to pass the arguments
> from the enclosing context to f, but the more important thing is that f
> needs to be defined outside of foo, removed from the point of use. A local
> function decreases complexity, and it's much easier to grasp because it's
> just like an ordinary function, only defined inside of foo.

Sure, but its an awful lot of work to design, implement and maintain, especially
if its going to need its own peculiar syntax. Is the ability to define a
function inside another a great win?. The only use is as an argument to
functions that iterate through containers like std::for_each AFAICS.
(My overall point was that if there was a choice (due to finite resources)
between implementing local functions and implementing a standard GUI or Unicode
or threads, then I would take one of the latter).

>> 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?
> This is a pretty common view, but C++ has been missing essential standard
> libraries for more than ten years, and it still competes with Java. C++
> simply doesn't play by the marketing rule that whoever has the more
> checkboxes wins. It doesn't even have garbage collection! An automatic loss,
> you'd think.

In an ideal world it would be nice not to worry about object lifetimes. From the
current threads on clcm the garbage collection issue is not clear cut. My
current limited understanding is that it would be too great a distortion to the
current language to try to apply garbage collection( excepting smart pointers),
especially since it seems to violate the "you dont pay for what you dont use"
principle. Maybe C++ is showing its age though!

> Not only that; what standard libraries C++ does have are often simply not
> used (iostreams, locale.)

Are you suggesting that C++ shouldnt have a standard input/output mechanism?

FWIW mention of standard streams is apt. A GUI is just an alternative paradigm
for I/O. As far as most users of an application are concerned its a much
superior I/O mechanism than the command line AFAICS. OTOH If the command line
was superior
then all modern oses would just provide command line wouldnt they?

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at