Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Nested function
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Alternatives by language === The following languages provide features that are similar to nested functions: *[[C++]] {{endash}} classes allow for similar data hiding and encapsulation; defining a class within a class provides similar structure (see [[Function object#In C and C.2B.2B|Function object in C++]]) *[[C++11]] and later {{endash}} via lambda expressions (see quicksort example above)<ref>{{Cite web|url=http://www.rosettacode.org/wiki/Nested_function#C.2B.2B|title = Nested function - Rosetta Code}}</ref> *[[Eiffel (programming language)|Eiffel]] {{endash}} explicitly disallows nesting of routines to keep the language simple; does allow the convention of using a special variable, '''Result''', to denote the result of a (value-returning) function *[[C Sharp (programming language)|C#]] and [[Visual Basic .NET|Visual Basic]] {{endash}} via lambda expressions *[[Java (programming language)|Java]] {{endash}} since Java 8, via [[Anonymous function#Java|lambda expressions]]<ref>{{Cite web|url=http://www.rosettacode.org/wiki/Nested_function#Java|title = Nested function - Rosetta Code}}</ref><!--How can a lambda expression "simulate" nested scopes, in any number of levels, containing any language element (functions, variables, constants, types) ?-->, and in older versions, via an [[anonymous class]] containing a single method
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)