From 2784190084971944016
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: James Kuyper <kuyper@wizard.net>
Subject: Re: nested functions
Date: 1999/06/15
Message-ID: <3763A8D5.9786D8C2@wizard.net>#1/1
X-Deja-AN: 489736432
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7jd4c5$nup$1@nnrp1.deja.com> <7jjjr6$r02$1@nnrp1.deja.com> <7jma5c$i85@abyss.West.Sun.COM> <7jmdcv$a56$1@engnews1.eng.sun.com> <7jrqf5$op5$1@nnrp1.deja.com> <7jrv0r$dfq$1@engnews1.eng.sun.com> <081650426190c69CPIMSSMTPU07@email.msn.com>
X-Original-Date: Sun, 13 Jun 1999 08:49:25 -0400
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 929427975 14370 128.250.29.16 (15 Jun 1999 06:26:15 GMT)
Organization: Not Enough
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN2Xx9+EDnX0m9pzZAQHlzwF/YKZ2ZOMYN5wIs3bvOfxk3ITLsg1hFe2x WJysjm3+JOkG2Sh0EXeTTP0DhIhWyaJg =YCZR
Mime-Version: 1.0
NNTP-Posting-Date: 15 Jun 1999 06:26:15 GMT
Newsgroups: comp.std.c++

G.B. wrote:
....
> The difference between local and global fiunctions is that the first can
> access local variables (including parent function parameters) in the scope
> where they are defined. These local variables simply do not exist when you
> leave the scope, so calling local function out of it parent's scope doesn't
> make sense.

Just because a function is being called outside the parent's scope
doesn't mean that the parent's scope has ended. 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.
---
[ 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              ]



