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

Are svn_fs_dir_t and svn_fs_file_t worth it?

From: Jim Blandy <jimb_at_savonarola.red-bean.com>
Date: 2000-11-09 01:01:20 CET

At the moment, the filesystem interface has three types that refer to
objects in the filesystem:

   svn_fs_dir_t --- a directory
   svn_fs_file_t --- a file
   svn_fs_node_t --- either a directory or a file

There is a set of systematically named functions for casting dirs and
files to nodes, and casting nodes to either dirs or files; the latter
functions indicate an error if the node is not actually a dir or file.

The original motivations for providing these three types in their
little hierarchy were these:
- In many cases, the compiler can tell you if you've passed a
  directory when a file is required, or vice versa, at compile time.
- It makes function prototypes somewhat self-documenting.
- Even though every node is a directory or file, having a type for
  nodes lets you define a single operation that works on all kinds of
  nodes.

However, in the filesystem code itself, I've encountered the following
consequences:
- Calls to the casting functions are pretty frequent, even though they
  serve no function other than making the static typing work out.
  It's somewhat obscure.
- If I need to use functions specific to a given node kind, and also
  functions that work on any kind of node, I end up with making a
  `convenience' (heh.) copy of the variable:

      svn_fs_dir_t *foo_dir;
      svn_fs_node_t *foo_node = svn_fs_dir_to_node (foo_dir);

  It's pretty bureaucratic.

So I think I'd like to eliminate svn_fs_dir_t and svn_fs_file_t, and
use svn_fs_node_t throughout. It would make svn_fs_node_t more like
Unix file descriptors --- a uniform way to reference whatever's out
there.

What do folks think? Greg, I'm especially interested in your opinion,
since you've actually written code that uses the fs interface.
Received on Sat Oct 21 14:36:14 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.