On 11.02.2011 21:37, Daniel Becroft wrote:
> On Sat, Feb 12, 2011 at 6:07 AM, Grigory Petrov <grigory.v.p_at_gmail.com>wrote:
>
>> Hello.
>>
>> I'm learning subversion API right now and examining it's source code and
>> examples. It's a lot of things in subversion source code that is called a
>> "baton". For example, svn_cmdline_create_auth_baton() create "auth baton",
>> and callbacks takes callback function pointer and, again, batons. I never
>> heard of a term "baton" related to the programming. That is the "baton"
>> concept subversion source code refers to? Maybe i can read somewhere about
>> "batons" used in programming? Or is it a well-known term of some origin?
>>
>> Best,
>> Grigory.
>>
> I don't know about subversion, but I'm guessing the origin of the baton
> concept came from the running race [1], where an item is passed from runner
> to runner. Historically, this baton would have some information on (or in)
> it, that needed to get to its destination quickly.
>
> Not to be confused with baton twirling, though. [2]. :-)
>
> [1] http://en.wikipedia.org/wiki/Baton_%28running%29
> [2] http://en.wikipedia.org/wiki/Baton_twirling
The name does, in fact, come from the conductor's baton. The programming
paradigm is old as programming itself, what we call a "baton" in SVN
sources is variously called "userdata", "state", "context", etc. in
other APIs that make use of callbacks.
Its function is to allow the user of an API to pass an opaque object
that gets passed back through callbacks so that the caller does not have
to maintain a seprate context-discovery mechanism.
-- Brane
Received on 2011-02-11 22:16:05 CET