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