From -308374105286704736
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: Lisa Lippincott <lisa_lippincott@advisories.com>
Subject: Re: nested functions
Date: 1999/06/23
Message-ID: <160619991237064992%lisa_lippincott@advisories.com>#1/1
X-Deja-AN: 492864317
Content-Transfer-Encoding: 8bit
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
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> <7k5vjh$r0d$1@nnrp1.deja.com>
Mail-Copies-To: poster
X-Original-Date: Wed, 16 Jun 1999 12:37:06 -0700
Content-Type: text/plain; charset=ISO-8859-1
Organization: -
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN3CezqwEuYhIxRhxAQHdWwH7BcRFhHBgmRJtafDPz69pWTkQZD1y2OUu vZmEHNpodgiCCIpT4X0Ixs18u2X6LfZgPdMDhfMmbRtHrEG21Dlbxg== =jPAJ
Mime-Version: 1.0
User-Agent: YA-NewsWatcher/4.2.2
Newsgroups: comp.std.c++

James Kanze <James.Kanze@dresdner-bank.com> asks:

> Just a question of vocabulary, but what is a closure, exactly.  I've
> always thought that, in layman's terms, it extended the life of the
> local context beyond the return from the function.  I think that this is
> how it works in lisp (but my lisp experience is limited to customizing
> emacs, so I'm not sure).  And of course, Borland has invented a totally
> different meaning.  What you are describing would seem to be closure as
> I understand it, but without the extended lifetime.

There's a common meaning to all of these uses of "closure": a closure
is a new function created by fixing some of the parameters to an
existing function.  Thus the one-parameter function "add three" is a
closure of the two-parameter function "add."

The confusion you express comes from interpreting "closure" in radically
different environments.  Lisp's rules of scope (functions may access
objects defined in their callers) and lifetime (if it's accessible, it's
alive) give Lisp's closures properties which seem bizzare from a C++
point of view.

                                             --Lisa Lippincott
---
[ 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              ]



