From -2782580587251228013
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: stanley@West.Sun.COM (Stanley Friesen [Contractor])
Subject: Re: nested functions
Date: 1999/06/16
Message-ID: <7k610k$pp7@abyss.West.Sun.COM>#1/1
X-Deja-AN: 490113689
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7jd4c5$nup$1@nnrp1.deja.com> <7jrv0r$dfq$1@engnews1.eng.sun.com> <081650426190c69CPIMSSMTPU07@email.msn.com> <3763A8D5.9786D8C2@wizard.net>
X-Original-Date: 15 Jun 1999 17:03:16 GMT
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 929505541 16685 128.250.29.16 (16 Jun 1999 03:59:01 GMT)
Organization: SunSoft South, Los Angeles, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN2cg9OEDnX0m9pzZAQFRuQGAo79lzsnM4PGwPXdYpa9tI3geVazHGZbL Yxj2x0cDa5m4+4ENKY1TqCw5dN+q1xL7 =pAPD
NNTP-Posting-Date: 16 Jun 1999 03:59:01 GMT
Newsgroups: comp.std.c++

In article <3763A8D5.9786D8C2@wizard.net>,
James Kuyper  <kuyper@wizard.net> wrote:
>
>Just because a function is being called outside the parent's scope
>doesn't mean that the parent's scope has ended.

I guess the problem here is an ambiguity in the phrase "outside of the
parent's scope".  Once can interpret being in a function called by the
the parent function as still being "in" the parent's scope in some sense.

> In fact, that's exactly
>the case in one of the examples you gave:
>
>> void Container::DoSomethingToAll(/* function parameters */)
>> {
>>   // local variables
>>   void DoSomethingToOne(T& t) { /* use t, local variables and function
>> parameters */ }
>>   ForEach(DoSomethingToOne);
>> }
>
>Therefore, the question of whether it's possible/desirable to allow
>local function pointers to exist and be interchangable with global
>function pointers is very relevant.

Well, based solely on this example I do not see why ForEach needs to be
declared to take a generic function pointer.  It could easily be declared
to take a nested function pointer.  Or it could, even better, be declared
as a template. (To be general it needs to be a template anyhow, since
function pointers with different signatures are not interchangeable as it
is, so nothing is lost by doing so).
---
[ 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              ]



