From -2099578684601788107
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: Andrei Alexandrescu <andrewalex@hotmail.com>
Subject: Re: nested functions
Date: 1999/06/15
Message-ID: <7k5ncv$n8u$1@nnrp1.deja.com>#1/1
X-Deja-AN: 489867867
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> <FD38vK.CC4@research.att.com> <7jrpss$ogk$1@nnrp1.deja.com> <FqA83.38464$wk2.553149@newscene.newscene.com> <37659D89.565ACF7D@technologist.com>
X-Original-Date: Tue, 15 Jun 1999 14:19:22 GMT
X-Http-User-Agent: Mozilla/4.51 [en] (Win98; U)
X-Http-Proxy: 1.0 x28.deja.com:80 (Squid/1.1.22) for client 63.65.42.201
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Tue Jun 15 14:19:22 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN2ZlAawEuYhIxRhxAQHOfQH/VH3bLf9JJRD7Aw4KASd6w6Jgp6bN4kcU PLXwgs8vx6j4Fv97Lggrs0ws3TEYF4lNIiKUh6M9exwfo4JayfMI0A== =W1li
Newsgroups: comp.std.c++

In article <37659D89.565ACF7D@technologist.com>,
  David R Tribble <dtribble@technologist.com> wrote:
> I disagree; I don't think it makes much sense to call or pass a
> pointer to a local function to functions outside its scope (i.e,
> outside its enclosing function).  It's analogous to passing pointers
> to local structures to other functions outside the function containing
> the structure declaration.

I'm afraid you are wrong.
Passing pointers to local functions to the outside is fundamental to
LISP-like languages. One basically cannot program in LISP without that.
Your analogy doesn't hold. One reason is that it's wrong :o). I have
cases when I return pointers to local structs. The point is, local
structs inherit global structs:

class Base { ... };

auto_ptr<Base> f()
{
    class Derived : public Base { ... };
    return auto_ptr<Base>(new Derived);
}

> On the other hand, it seems entirely reasonable to pass pointers
> to local functions to other functions within the same scope of the
> outer function.

IMHO you have a peculiar way of concluding what's reasonable and what's
not. All other participants agree that if local functions will be
allowed, one should be able to pass them to the outside world in a way
or another. The debate is whether/how they fit the general design of
C++, and how they can be implemented.

> P.S.  I personally don't see any need for nested functions.

I do. (It's true no single language feature is have-it-or-die, though.)
The problem is, they are hard to implement in the context of the C++
language.

Andrei



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ 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              ]



