Everything2
Near Matches
Ignore Exact
Full Text
Everything2

callback

created by JeffMagnus

(thing) by WWWWolf (1.4 y) (print)   ?   (I like it!) Thu Aug 17 2000 at 7:18:30

Generally, in GUI programming, callback is a function that handles some event. For example:

  glutMouseFunc(mouse);

With this command, GLUT program will then use function mouse as callback to handle mouse clicks. Example:


void mouse(int button, int state, int x, int y)
{
  switch(button) {
  case GLUT_LEFT_BUTTON:
    if(state==GLUT_DOWN)
      clicked(x,y);
    break;
  case GLUT_MIDDLE_BUTTON:
    if(state==GLUT_DOWN)
      reset_state();
    break;
  }
}

This callback will receive mouse button state and click coordinates through the function parameters.

Callbacks aren't always called callbacks, but the idea is same often in GUI programming. =)


(idea) by Rancid_Pickle (4.5 d) (print)   ?   (I like it!) Sat Jan 20 2001 at 5:51:03

Callback is a form of remote network security. When a remote device calls in and is authenticated, the system disconnects and calls a preset number. Theoretically, the preset number is the remote device that initiated the connection. Should an intruder attempt to connect, they must be either tapping the phone line or have broken into the physical location of the remote device.

(thing) by ariels (1.3 d) (print)   ?   (I like it!) 1 C! Thu Jan 25 2001 at 7:54:15

A high-level routine called from a low-level routine.

Software systems are usually built in a hierarchical fashion: higher-level routines call lower-level routines, which perform services on their behalf. For example, an application program might invoke a GUI library or an XML library.

The normal way a library communicates with its caller is by return value. That is, function f() calls library function g(); when g() returns, various variables in f() are set; f() interprets these results, which g() generated for it. Note that this method of communication requires the library routine to terminate to allow communication to take place.

But what if the library routine must communicate with the caller without returning? (Programmers from the 1970s use coroutines to do this kind of thing; it's not too different in practice) For instance, in a GUI application the event loop might be a library routine, but the application has to perform actions in response to GUI events. A program using an XML parser could be returned a parse tree of the input, but that wastes memory if the program isn't interested in most of the items, and it relegates to the program the generic task of correctly traversing the tree.

The solution is to employ callbacks. The library is instructed to call various routines on certain conditions. For instance, a GUI library might be told to call a certain routine when a certain slider is moved; an XML library might be told to pass a certain routine the contents of a document's <TITLE> tag. Specifying a long list of such callbacks ties the library routine's generic functionality to the specific functionality the caller requires.

In C, callbacks are generally specified with function pointers to the application-level functions; these functions are called with parameters defined in the library API. A good callback API will always pass a parameter of type void * pointing to "callback data"; this parameter is passed in from the application, and can be used to point to some application-specific data. C++ allows more exotic means of calling functions; callbacks are generally functors (or function objects), and don't require an extra typeless parameter passed from the library. Function languages and languages in the Lisp family have first-class functions with closures which can be utilised directly for callbacks.


(thing) by cheshious (4.9 y) (print)   ?   (I like it!) Sun May 04 2003 at 0:23:01

In theater (or, if you prefer, theatre) callbacks are that wonderfully indeterminate stage between going to the audition and possibly actually getting cast.

Callbacks are rarely like another audition. In a typical audition, you perform one or two prepared monologues and possibly a musical number or two; in some cases, you do a cold reading of the play, maybe even with somebody. In a callback, you are often thrown a script, a scene partner (or eight) and told to go to it. Sometimes, you get a few minutes to rehearse. The director usually plays a sort of round robin, shuffling scene partners like a bridge deck.
Group warm-ups are often a feature of callbacks; I think it's a method to guage how enthusiastic and willing the potential cast members are. Also included may be: comedy improv, script-related improv, miming, dance, movement, storytelling, and even singing or musical improv. It can get wacky.

There may be multiple rounds of callbacks; for big-time TV shows, nine or ten rounds of callbacks is not unheard-of. Callbacks are often fun, but, they can also be hella nerve-wracking.



Now, this is just my personal take on callbacks, so I could be wrong (any directors out there feel the need to correct me?). If you've only got one round of callbacks (e.g., if you got relatively few people for auditions), callbacks are often more confirmation than huge decision. It's just a method of making sure that the people you're casting can take it and making sure that those ones that showed promise but just didn't fit weren't having an off day (they can also serve as handy back-ups if the prima donna you had in mind turns out to be a total bitch). The bad part of this is that when it happens, you usually know. And when you know, you know which category you belong in; it's weird to be able to pick out the cast list before it gets posted (especially when you're not on it).

printable version
chaos

->* example of use of a function pointer Glut Tips for the first day of any college course
Flying by the seat of your pants void * C++: static extern "C" The Rocky Horror Picture Show
Playwright in tech White space functor glade
Hollywood principle cattle call co-routine Harvard Callbacks
GUI delegate AIM I Started a Joke
Richard Carl Heine em context
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
How do men touch you?
College of Cardinals
lime
Clipping
Do female homosexuals have it easier than male homosexuals?
The Russian Revolution: Fictional diary entries from a loyalist factory worker
poppy
The sad, sad mutant handbook
Dawn French
Grace
A medical explanation of the effects of ecstasy on your body
Nike
What Everything does better than anything else
New Writeups
Memento Mori
Do-It-Yourself Depression Control(person)
XWiz
Trism(review)
artman2003
Briefcase Full of Souls - Part I(fiction)
Dreamvirus
Alan Ladd(person)
waverider37
Harold Holt(person)
The Debutante
Until death do us part(fiction)
Ysardo
a brother to a sister(personal)
antigravpussy
your warm whispers(personal)
Clarke
Multiculturalism(idea)
aneurin
Earl of Landaff(person)
Heitah
Pseudocide(idea)
XWiz
Google Knol(lede)
Mythi
July 24, 2008(personal)
locke baron
The fall of Earth(fiction)
BookReader
Fear the Cold(dream)
Everything 2 is brought to you by the letter C and The Everything Development Company