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!
{{Short description|A named function defined within a function}} In [[computer programming]], a '''nested function''' (or '''nested procedure''' or '''subroutine''') is a [[identifier|named]] [[subroutine|function]] that is defined within another, enclosing, block and is [[lexically scoped]] within the enclosing block {{endash}} meaning it is only callable by name within the body of the enclosing block and can use [[identifiers]] declared in outer [[Block (programming)|blocks]], including outer functions. The enclosing block is typically, but not always, another function. <!-- Is there a clear but more concise wording? --> [[Programming language]] support for nested functions varies. With respect to [[structured programming]] languages, it is supported in some outdated languages such as [[ALGOL]], [[Simula 67]] and [[Pascal (programming language)|Pascal]] and in the commonly used [[JavaScript]]. It is commonly supported in [[dynamic language|dynamic]] and [[functional language|functional]] languages. However, it is not supported in some commonly used languages including standard [[C language|C]] and [[C++]]. Other programming technologies provide similar benefit. For example, a [[Lambda function (computer programming)|lambda function]] also allows for a function to be defined inside of a function (as well as elsewhere) and allows for similar data hiding and encapsulation. Notably, a lambda function has no name (is anonymous) and therefore cannot be called by name and has no visibility aspect.
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)