From -8518540715226893837
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: gbush@my-deja.com
Subject: Re: nested functions
Date: 1999/06/11
Message-ID: <7jrqf5$op5$1@nnrp1.deja.com>#1/1
X-Deja-AN: 488552111
X-NNTP-Posting-Host: 146.225.126.244
Approved: stephen.clamage@sun.com (comp.std.c++)
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>
X-UID: 0000000001
X-Status: $$$T
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
X-Http-Proxy: 1.1 x37.deja.com:80 (Squid/1.1.22) for client 146.225.126.244
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Fri Jun 11 20:10:20 1999 GMT
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <7jmdcv$a56$1@engnews1.eng.sun.com>,
  clamage@eng.sun.com (Steve Clamage) wrote:
> Consider function pointers:
>
> extern int f(int);
> extern int(fp*)(int);
>
> void g1()
> {
>     int h(int) { ... } // supposing C++ had local functions
>     fp = h;

This must be prohibited. It doesn't make sense to assign local function
pointer to the global variable. Local functions cannot be extern.

> If the calling sequences for g1::h and f are not the same,

There should not be such thing as g1::h. Local functions should be
visible only in the scope where they are defined.

> the code can't work. Either you need a different kind of
> function pointer for local functions, or you extend the
> calling sequence of global functions to match that of local
> functions.

You don't need a different kind of pointer for local functions. You
just don't call them from out of scope.

> Given the amount of complexity, and that you can get many of
> the effects of local functions with function objects or with
> classes in general, adding local functions didn't seem like
> a big win for C++.
There is no "amount of complexity", it works great in Pascal and is
very usefull.

Gene.


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              ]




