From 5307902928653902141
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: stanley@west.sun.com (Stanley Friesen [Contractor])
Subject: Re: nested functions
Date: 1999/06/09
Message-ID: <7jma5c$i85@abyss.West.Sun.COM>#1/1
X-Deja-AN: 487589446
X-Nntp-Posting-Host: ba2.west.sun.com
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7jd4c5$nup$1@nnrp1.deja.com> <7jjjr6$r02$1@nnrp1.deja.com>
Organization: SunSoft South, Los Angeles, CA
X-UID: 0000000001
X-Status: $$$T
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <7jjjr6$r02$1@nnrp1.deja.com>,  <wmm@fastdial.net> wrote:
>In article <7jd4c5$nup$1@nnrp1.deja.com>,
>1) Runtime overhead.  The function calling sequence has to be
>modified to maintain a display pointer or the like. ...

Why do local functions have to have the same calling sequence as non-local
functions?  Given the C++ requirement for all functions to be declared
prior to a call, the compiler can always tell if a call is to a namespace
scope funcion or to a local one.
>
>2) Implementation complexity.  Although the problems are well
>understood from experience with other languages, people felt that
>the utility of nested functions was sufficiently limited that it was
>not a good tradeoff.

2.5) The potential for writing obscure code due to "hidden" references
to mid-scope variables is not worth the small gain in utility.

[One of the hardest to maintain programs I ever saw was an assembler
written in Pascal that made heavy use of local functions, and of the local
function's ability to access variables in containing functions].
>
>3) C data compatibility.  A function pointer in C is a simple object,
>just the address of the code of the function.  A pointer to a nested
>function is more complex, requiring a pointer to the automatic
>storage area.  ...

Since pointer-to-member-functions are already non-compatible with ordinary
function pointers, why do pointers to local functions need to be compatible
either?  Why not just use a different category of pointers for pointers
to local functions?


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




