From -4079414850451473743
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a69618ea97f65037
X-Google-Attributes: gidf78e5,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: nested functions
Date: 1998/05/04
Message-ID: <354DC34A.37280BCE@physik.tu-muenchen.de>#1/1
X-Deja-AN: 351026238
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <6hac23$8lb$1@news2.isdnet.net> <353b85b9.0@news.iprolink.ch> <sfn2dcncm2.fsf@bidra168.bbn.hp.com> <35459993.3BC581B0@physik.tu-muenchen.de> <199804281743.NAA18001@calumny.jyacc.com> <35472A6D.562EA04C@physik.tu-muenchen.de> <t7wwc8d0o2.fsf@calumny.jyacc.com>
Mime-Version: 1.0
Originator: clamage@taumet
X-Nntp-Posting-Host: coulomb.t30.physik.tu-muenchen.de
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset=us-ascii
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Newsgroups: comp.std.c++


Hyman Rosen wrote:
> 
> Christopher Eltschka <celtschk@physik.tu-muenchen.de> writes:
> > But as long as f didn't return, you don't need a closure mechanism,
> > as the usual nested function mechanism would work well.
> 
> Perhaps I am misusing the term closure? I understand a closure to be the
> combination of a function pointer plus a set of stack frame pointers, one
> for each static nesting level of the pointed-to function. What do you mean
> by it? Are Scheme closures different? In Scheme, automatic variables can
> outlive the exit from their scope, but that's because Scheme is a garbage
> collected language. Java now has the same sort of thing.

Maybe my understanding of the term "closure" is wrong. The posting which
introduced the term to the thread spoke about "true closures" with an
example where the function context outlives the return, and the
behaviour
of the program demonstrated just this by creating two such contexts.
Also it mentioned the gcc model as not being "true closures". Therefore
I concluded that closures are function contexts which "survive"
the return of the function (which makes sense as those contexts are in
some way "closed" by the return: they cannot be accessed directly
any more, but only indirectly by the local functions).

BTW, you don't need a frame pointer for each nesting level. You
just need one for the level below. From there, you can get to the other
levels sequencially.


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




