472,328 Members | 1,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Re: Return of nested function

Nick Keighley schrieb:
>- I use GCC (and its extension for the nested functions)

ah. As you note this is a gcc extension. You need to ask on
a gcc group for the exact semantics of their nested functions
Why is there actually a *need* for nested functions? If functionality of
subfunctions which are only locally visible is desired, why not put the
nesting function parent and its nested children all in one module,
declare the children static - voila. Std-C.

Regards,
Johannes

--
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electronics <47***********************@news.freenet.de>
Jul 15 '08 #1
2 1547
Johannes Bauer wrote:
Nick Keighley schrieb:
>>- I use GCC (and its extension for the nested functions)

ah. As you note this is a gcc extension. You need to ask on
a gcc group for the exact semantics of their nested functions

Why is there actually a *need* for nested functions? If functionality of
subfunctions which are only locally visible is desired, why not put the
nesting function parent and its nested children all in one module,
declare the children static - voila. Std-C.
It's possible (even likely) that the GCC semantics is more powerful
than this would allow. For example, it might implement Pascal-style
nesting, where functions can refer to the locals of the functions
they are nested in while those functions are still executing.

/Clearly/ you can fabricate code to get round this, unless (as
you likely will) you have to pass your function-plus-fabrications
through a function-pointer-sized-and-typed slot. Oops.

--
If you read the signature, the signature reads you. - eh

Hewlett-Packard Limited Cain Road, Bracknell, registered
no:
registered office: Berks RG12 1HN 690597
England

Jul 15 '08 #2
In article <30************@joeserver.homelan.net>,
Johannes Bauer <df***********@gmx.dewrote:
>Why is there actually a *need* for nested functions? If functionality of
subfunctions which are only locally visible is desired, why not put the
nesting function parent and its nested children all in one module,
declare the children static - voila. Std-C.
Is there actually a *need* for local variables? If functionality of
variables which are only locally visible is desired, why not put the
function in a file by itself and declare the variables static at file
scope - voila.

The point, of course, is that nested functions can do more than
control the visibility of the function name. They let you create
closures - instances of functions that are "closed" over the bindings
of variables in enclosing scopes.

[Yes, you could have an implementation of nested functions that didn't
provide this, just as you could have an implementation of local
variables that didn't make recursive calls work. Then they really
wouldn't be much use.]

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Jul 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested...
5
by: Andrew Poulos | last post by:
If I'm searching for an occurance of a value in a multi-dimensional array how can I get it's index returned as an array, if found? For example, if:...
5
by: Agnes | last post by:
Can combo box return more that 1 item ?? for my currency combo box, short_code, descripiton, currency rate. as user choose the description, I need...
1
by: moondaddy | last post by:
I need to return a nested string array from a function and am getting hung up on syntax. Here's a simple example of a function that returns the...
77
by: Peter Olcott | last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html The above link shows that C# is...
14
by: Alexander Stoyakin | last post by:
Hello! Please advise on the following issue. I have a function which returns 1 or 0 in multiple branches, and it must perform the same code before...
4
by: Wolfgang Draxinger | last post by:
If you know languages like Python or D you know, that nested functions can be really handy. Though some compilers (looking at GCC) provide the...
11
by: =?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?= | last post by:
Hello, I have a question about the infamous GOTO statement and the way to return a result from a sub: I have a sub that has to make some...
4
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.