From 1596647755838092713
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a69618ea97f65037
X-Google-Attributes: gidf78e5,public
From: "Bradd W. Szonye" <bradds@concentric.net>
Subject: Re: nested functions
Date: 1998/04/29
Message-ID: <3545EA31.DE87C4E6@concentric.net>#1/1
X-Deja-AN: 348618722
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
Content-Transfer-Encoding: 7bit
References: <6hac23$8lb$1@news2.isdnet.net> <353A6B2D.C2904893@concentric.net> <353F43D1.2781E494@ips.cs.tu-bs.de>
X-Original-Date: 28 Apr 1998 10:38:51 EDT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: Concentric Internet Services
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANUaZAuEDnX0m9pzZAQGpLgF/a+y4eGF8yDq7shLuc6Gsto+MQwAPrJr6 yQeMN44I+OOBO/UvRZfVPrIgIv9ZYulP =znx/
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.

Andreas Rossberg wrote:
> 
> 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).

Okay, no argument there. I thought the original poster was talking about
the 'toy' local functions in, say, Pascal, not the higher-order
functions available in functional programming languages, which I'll
agree are very powerful.

I'd put simple local functions in the same category as the 'super'
facility: nice to have, but not necessary if there are other features
more important to develop in the time available. Just as 'super' is
possible (more or less) with 'typedef base base_type,' simple local
functions are possible with the unnamed namespace and functor classes.

As for closures, that's a very interesting addition to the language...
but the interactions with the C++ object lifetime model could get nasty.
Also, what is the possibility of a roll-your-own closure with the
facilities already available in C++? I'm not especially knowledgeable
about the issues in implementing closures; functional programming is
just an occasional hobby for me, and I'm much more familiar with, say,
implementation of polymorphism, heap memory management, and exception
handling.

(If answers to that question are too far off-topic, e-mail me comments,
but please let me know whether it's a CC.)
-- 
Bradd W. Szonye
bradds@concentric.net
http://www.concentric.net/~Bradds

My reply address is correct as-is. The courtesy of providing a correct
reply address is more important to me than time spent deleting spam.
---
[ 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              ]



