By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,920 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,920 IT Pros & Developers. It's quick & easy.

Define callback

P: n/a
Can someone provide a fromal definition of "callback"? I see this term used
often, and can usually understand the discussion where it's used, but I
would be hard-pressed to provide a formal definition.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
* Steven T. Hatton:
Can someone provide a fromal definition of "callback"? I see this term used
often, and can usually understand the discussion where it's used, but I
would be hard-pressed to provide a formal definition.


Split a software system into two non-overlapping regions of code A and B.
An executable entity defined by A and passed as argument from A to some
routine in B for execution by B-code is a callback. In that sense member
functions can be and usually are callbacks, but most often "callback" is
used for and implies free functions and functor objects.

See also <url: http://www.google.com/search?q=define:callback>, and perhaps
also patents issued in the US... ;-)

XFUT [comp.programming].

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #2

P: n/a
Steven T. Hatton wrote:
Can someone provide a fromal definition of "callback"? I see this term used
often, and can usually understand the discussion where it's used, but I
would be hard-pressed to provide a formal definition.


see: http://www.newty.de/

Jul 23 '05 #3

P: n/a
Alf P. Steinbach wrote:
* Steven T. Hatton:
Can someone provide a fromal definition of "callback"? I see this term
used often, and can usually understand the discussion where it's used,
but I would be hard-pressed to provide a formal definition.


Split a software system into two non-overlapping regions of code A and B.
An executable entity defined by A and passed as argument from A to some
routine in B for execution by B-code is a callback. In that sense member
functions can be and usually are callbacks, but most often "callback" is
used for and implies free functions and functor objects.

See also <url: http://www.google.com/search?q=define:callback>, and
perhaps also patents issued in the US... ;-)

XFUT [comp.programming].


This is a perfectly legitimate question on comp.lang.c++ considering that I
find the term in C++ documentation and text, and it is not commonly used in
discussing other programming languages I have used. It seems to be an
artifact of C++'s C origins. For example, the term appears in the C++
standard, but not in the GNU Emacs Lisp Reference Manual, nor in the Java
Language Specification. In Pascal what you seem to be describing are
called procedural parameters and functional parameters.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
Jul 23 '05 #4

P: n/a
Steven T. Hatton wrote:
[snip]
For example, the term appears in the C++
standard, but not in the GNU Emacs Lisp Reference Manual, nor in the Java
Language Specification. In Pascal what you seem to be describing are
called procedural parameters and functional parameters.


"The term" being a callback, Java does not mention it because it doesn't
have a direct analog. In current implementations, you pass an object
implementing an interface rather than a function, and functors have no
Java analog from C++.

In LISP, isn't a function considered a first class object just as a
class instance or list or atom, and so you can pass anything around as
data? Other similar languages like Mozart-oz and many scripting
languages do.

--Paul
Jul 23 '05 #5

P: n/a
Paul Bilnoski wrote:
Steven T. Hatton wrote:
[snip]
For example, the term appears in the C++
standard, but not in the GNU Emacs Lisp Reference Manual, nor in the Java
Language Specification. In Pascal what you seem to be describing are
called procedural parameters and functional parameters.


"The term" being a callback, Java does not mention it because it doesn't
have a direct analog. In current implementations, you pass an object
implementing an interface rather than a function, and functors have no
Java analog from C++.

In LISP, isn't a function considered a first class object just as a
class instance or list or atom, and so you can pass anything around as
data? Other similar languages like Mozart-oz and many scripting
languages do.

--Paul


The *idiom* may be used elsewhere. I would say it's used extensively in
Emacs Lisp, but not called "callback". I'm not sure it's used consistently
by C++ programmers. GoF calls parameterized behavior of an object (of class
type) a command pattern, and distinguishes between that and "callback"
which they say is the procedural language analog which 'command'
"replaces". That would imply that they would call
std::ios_base::event_callback a command pattern. But, I would say it is
closer to an observer pattern. Similar, but not identical to the Java
listener interface usage.

Part of my confusion comes from the networking notion of callback which
means if I hit a server (usually a dial up) with something that identifies
me, the server will then connect to a prespecified address(telephone
number).

It would seem that the meaning in the context of C++ is something like "a
function or functor that is assigned to a variable identifier so that it
will be invoked under prespecified conditions".
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
Jul 23 '05 #6

P: n/a
Steven T. Hatton wrote:
Can someone provide a fromal definition of "callback"? I see this term used
often, and can usually understand the discussion where it's used, but I
would be hard-pressed to provide a formal definition.


It seems to me, in my rather limited experience, that a callback has some kind of temperal implication.

You can "register" a callback, i.e., at some point you specify the callback function, and a later point, call it.

You can also store state somewhere, and later on invoke an action based upon that state.

I'm not sure how to formally define it, but I think there has to be some form of temperal description within any definition, otherwise it's a just a function call.

At a higher level, perhaps a callback is a description you give to an entity, describing how it should inform you of some event (which occurs at a later point in time).

Discuss :-p

Ben
--
I'm not just a number. To many, I'm known as a String...
Jul 23 '05 #7

P: n/a
Steven T. Hatton wrote:
Can someone provide a formal definition of "callback"?
I see this term used often and can usually understand the discussion where it's used
but I would be hard-pressed to provide a formal definition.

http://en.wikipedia.org/wiki/Callback

http://wombat.doc.ic.ac.uk/foldoc/

http://www.bartleby.com/61/

In C++ these are function pointers

1. passed as an argument to another function,
2. stored in a data object (like a virtual function table)
for later use and
3. objects with overloaded operator() [functors].
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.