[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Introduction

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2001-01-19 19:01:17 CET

> 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

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.