Closure (computer programming): Difference between revisions

Content deleted Content added
Small WP:COPYEDITs WP:EoS: WP:TERSE, clarify. WP:LINK update-standardize. Cut needless carriage returns in sentences, paragraphs, section. WP:CATEGORYs reorder-alphabetize.
m Callbacks (C): MOS:FIRSTABBReviation clarify, define before WP:ABBR in parentheses. WP:LINKs: add, update-standardize, plural > WP:SINGULAR. Nonlead-word nonproper noun MOS:CAPS > WP:LOWERCASE sentence case.
Line 331:
Some [[C (programming language)|C]] libraries support [[Callback (computer programming)|callbacks]]. This is ometimes implemented by providing two values when registering the callback with the library: a function pointer and a separate <code>void*</code> pointer to arbitrary data of the user's choice. When the library executes the callback function, it passes along the data pointer. This enables the callback to maintain state and to refer to information captured at the time it was registered with the library. The idiom is similar to closures in functionality, but not in syntax. The <code>void*</code> pointer is not [[Type safety|type safe]] so this C idiom differs from type-safe closures in C#, Haskell or ML.
 
Callbacks are extensively used extensively in [[graphical user interface]] (GUI) [[Widgetwidget toolkitstoolkit]]s to implement [[Eventevent-driven programming]] by associating general functions of graphical widgets (menus, buttons, check boxes, sliders, spinners, etc.) with application-specific functions implementing the specific desired behavior for the application.
 
====Nested function and function pointer (C)====