From 5345170805110154190
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: clamage@eng.sun.com (Steve Clamage)
Subject: Re: nested functions
Date: 1999/06/15
Message-ID: <7jvhah$5n3$1@engnews1.eng.sun.com>#1/1
X-Deja-AN: 489736431
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: 13 Jun 1999 05:58:41 GMT
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 929427965 14512 128.250.29.16 (15 Jun 1999 06:26:05 GMT)
Organization: Sun Microsystems Inc., Mountain View, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN2Xx7eEDnX0m9pzZAQGsxAF+NyXgjd0rrM8szKUxlJuRiWZozcHouEtq DaVr7wiYHR87iJkqrxtH4Tu6+4i4Io1I =eix2
NNTP-Posting-Date: 15 Jun 1999 06:26:05 GMT
Newsgroups: comp.std.c++

"G.B." <gb@web1.ucar.edu> writes:

>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.

Of course it does. That is how you implement a closure. It's
the one nice feature of local functions for which C++ does
not already have an equivalent.

--
Steve Clamage, stephen.clamage@sun.com
---
[ 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              ]



