From -1216501457256077239
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a69618ea97f65037
X-Google-Attributes: gidf78e5,public
From: Andreas Rossberg <rossberg@ips.cs.tu-bs.de>
Subject: Re: nested functions
Date: 1998/04/23
Message-ID: <353F43D1.2781E494@ips.cs.tu-bs.de>#1/1
X-Deja-AN: 348251337
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
Sender: news@ips.cs.tu-bs.de (News Software)
References: <6hac23$8lb$1@news2.isdnet.net> <353A6B2D.C2904893@concentric.net>
Mime-Version: 1.0
Originator: clamage@taumet
X-Nntp-Posting-Host: infbssts.ips.cs.tu-bs.de
Content-Type: text/plain; charset=us-ascii
Organization: TU Braunschweig, Abteilung Softwaretechnik
Newsgroups: comp.std.c++


Bradd W. Szonye wrote:
> 
> Nesting functions can be a useful scoping construct, but they add little
> new utility or expressiveness to a language, so their absence is
> generally not seen as a major failing of C or C++, except by advocates
> of languages that do support function nesting.

True nested functions (ie. closures) are a _very_ powerful feature that
is absolutely essential if you're seriously using functionals (functions
taking function(pointer)s as argument, also called higher-order
functions). For example, would C++ have closures then the whole tedious
business with iterators in the STL would be almost redundant, because
you can factor out the most common kinds of iterations over arbitrary
containers into a small set of simple library template functions like
iterate, fold, map, etc. that do the looping for you (possibly in an
optimized way) while you just supply the 'body' -- as a simple local
function given directly.

That's why programs in functional languages tend to be shorter by a
factor of 10 than equivalent C/C++ code. A language with good support
for higher-order functions and appropriate libraries highly increases
productivity and modularity. So your statement is plainly false.

-- 
Andreas Rossberg, rossberg_antispam@ips.cs.tu-bs.de
Please remove the `_antispam' when replying via email.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




