> First, you seem to be useing some data structure called a 'baton' in
> a lot of places in the code. From what I can glean from the code,
> it seems to just be a data structure that is passed around to
> represent the various characteristics of an entity in the repository
> (say a directory of a file or somthing like that).
Subversion makes a lot of use of functional abstractions ("walk the
tree of files, and whenever you see a frobnitz, do *this*"). Since C
doesn't have closures, a functional abstraction generally takes the
form of a function pointer plus a void * argument which gets passed
into the function. In various projects, such a function pointer is
called "userdata" or "arg"; we call it "baton".
So a baton isn't a specific data structure; it's a name for "something
that gets passed around," or specifically, something which gets stored
along with a callback and passed to the callback when it is called.
In at least one case, we encapsulate the baton with the callback
function(s) into a single object; the case I'm thinking of is generic
byte streams. Since we use generic byte streams in a lot of cases,
it's convenient to pass around a single argument instead of two. I'd
like to see us do this encapsulation in more places (instead of
edit_fns, we could have an "editor" structure which contains the
edit_fns callbacks plus the baton; we could have "text delta window
streams", etc.), but at some point such refinements become just navel
gazing. :)
Received on Sat Oct 21 14:36:19 2006