From -3756536771855385119 X-Google-Language: ENGLISH,ASCII X-Google-Thread: f78e5,a69618ea97f65037 X-Google-Attributes: gidf78e5,public From: JG@opticon.demon.co.uk (John Goodwin) Subject: Re: nested functions Date: 1998/05/05 Message-ID: <354f37ad.510389881@news.demon.co.uk>#1/1 X-Deja-AN: 351661403 X-NNTP-Posting-Host: opticon.demon.co.uk:158.152.54.193 Approved: stephen.clamage@sun.com (comp.std.c++) References: <6hac23$8lb$1@news2.isdnet.net> X-UID: 0000000001 X-Status: $$$T X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 894384791 nnrp-05:12664 NO-IDENT opticon.demon.co.uk:158.152.54.193 Organization: Opticon Newsgroups: comp.std.c++ Originator: clamage@taumet On 19 Apr 98 03:54:41 GMT, "Lo�c Tr�gan" wrote: >Are nested functions a good thing ? (of course, i have my opinion...) > >void f() >{ > void InternalA() {} > void InternalB() {} > > InternalA(); > InternalB(); >} > >if YES, why they are nt in the draft ? >if NO, why are they allowed in C and not C++ ? > >thanks. >--- I was once involved in an audit on a program of around 110,000 lines of code. It was believed to contain about a dozen goto's, but in fact turned out to have around 100. On investigation it was found that EVERY SINGLE ONE of the goto's was there because a local function was required. Some of the drones who considered themselves "purists" wanted the code modified with semaphores and extra if statements, but sanity ruled, and the goto,s were allowed to stand. It would have been nice to be able to replace them tidily with local functions but .... ----------- I've now read the rest of the thread, and realise that what I would like is a very small subset of what could be involved in providing local functions. To handle the cases I have in mind, you can put two restrictions on your local functions: 1) No address taking. 2) No other local function of the calling function is in scope inside the local function. This creates no extra overhead, and would provide a significant benefit in those cases where it is needed. But it's not going to happen so I suppose we'll just have to accept it. JG [ 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 ]