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
Callback (computer programming)
(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!
== Implementation == The callback technology is implemented differently by [[programming language]]. In [[Assembly language|assembly]], [[C (programming language)|C]], [[C++]], [[Pascal (programming language)|Pascal]], [[Modula2]] and other languages, a callback function is stored internally as a [[function pointer]]. Using the same storage allows different languages to directly share callbacks without a [[program lifecycle phase|design-time or runtime]] [[interoperability]] [[Abstraction layer|layer]]. For example, the [[Windows API]] is accessible via multiple languages, compilers and assemblers. C++ also allows objects to provide an implementation of the function call operation. The [[Standard Template Library]] accepts these objects (called ''[[function object|functors]]'') as parameters. Many [[Dynamic programming language|dynamic languages]], such as [[JavaScript]], [[Lua (programming language)|Lua]], [[Python (programming language)|Python]], [[Perl]]<ref>{{cite web |url=http://www.unix.org.ua/orelly/perl/cookbook/ch11_05.htm |title=Perl Cookbook - 11.4. Taking References to Functions|date=2 July 1999 |accessdate=2008-03-03}}</ref><ref>{{cite web |url=http://www.unix.org.ua/orelly/perl/advprog/ch04_02.htm |title=Advanced Perl Programming - 4.2 Using Subroutine References |date=2 July 1999 |accessdate=2008-03-03}}</ref> and [[PHP]], allow a function object to be passed. [[List of CLI languages|CLI languages]] such as [[C Sharp (programming language)|C#]] and [[VB.NET]] provide a [[type safety|type-safe]] encapsulating function reference known as [[Delegate (CLI)|delegate]]. Events and [[event handlers]], as used in .NET languages, provide for callbacks. Functional languages generally support [[first-class functions]], which can be passed as callbacks to other functions, stored as data or returned from functions. Many languages, including Perl, Python, [[Ruby (programming language)|Ruby]], [[Smalltalk]], [[C++]] (11+), C# and VB.NET (new versions) and most functional languages, support [[lambda (programming)|lambda expressions]], unnamed functions with inline syntax, that generally acts as callbacks.. In some languages, including [[Scheme (programming language)|Scheme]], [[ML (programming language)|ML]], JavaScript, Perl, Python, Smalltalk, PHP (since 5.3.0),<ref>{{cite web |url=https://secure.php.net/manual/en/functions.anonymous.php |title=PHP Language Reference - Anonymous functions | accessdate=2011-06-08}}</ref> C++ (11+), Java (since 8),<ref>{{cite web |url=http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html|title=What's New in JDK 8|work=oracle.com}}</ref> and many others, a lambda can be a [[Closure (computer science)|closure]], i.e. can access variables locally defined in the context in which the lambda is defined. In an [[object-oriented programming]] language such as [[Java (programming language)|Java]] versions before function-valued arguments, the behavior of a callback can be achieved by passing an object that implements an interface. The methods of this object are callbacks. In [[PL/I]] and [[ALGOL 60]] a callback procedure may need to be able to access local variables in containing blocks, so it is called through an ''entry variable'' containing both the entry point and context information. <ref>{{cite book |editor1-last=Belzer |editor1-first=Jack |editor2-last=Holzman |editor2-first=Albert G |editor3-last=Kent |editor3-first=Allen |title=Encyclopedia of Computer Science and Technology: Volume 12 |date=1979 |publisher=Marcel Dekker, inc. |isbn=0-8247-2262-0 |page=164 |url=https://books.google.com/books?id=IFmaqTI9-KsC&pg=PA164 |access-date=January 28, 2024}}</ref>
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)