Re: [notmuch] [PATCH] Added regress option to tags iterator

Subject: Re: [notmuch] [PATCH] Added regress option to tags iterator

Date: Mon, 21 Dec 2009 17:23:55 -0800

To: Ruben Pollan,


From: Carl Worth

On Wed, 09 Dec 2009 12:08:43 -0800, Carl Worth <> wrote:
> On Wed, 9 Dec 2009 14:24:46 +0100, Ruben Pollan <> wrote:
> > Do you like to call them regress? Should I change that?
> > What about the functions notmuch_*_is_first? Is kind of reversed logic than
> > notmuch_*_has_more, the last are true when is not reach the limit but the
> > first ones are true when the limit is reached. But I think it make sense like
> > that.

It doesn't make sense in the case of trying to write a for loop that
iterates in the reverse order. The is_first semantic doesn't give you
what you want for the loop-control portion of the for loop.

> I'd like a more symmetric API here. Anyone have a favorite set of names
> for iterating a list in two directions?

In some recent coding I needed to implement a new iterator so I had the
chance to think about this some more. Here is what I came up with:

  New function		Corresponds to existing function (if any)
  ------------		-----------------------------------------
  move_to_first		<implicit in iterator creation>
  has_next		has_more
  move_to_next		advance

  move_to_last		<none>
  has_previous		<none>
  move_to_previous	<none>

  get			get

The semantics of those all seem clear enough to me. They provide what's
necessary for all three portions of a for loop, (in either direction),
and everything pairs nicely.

The only downside is that the function names are a bit long in some
cases, but I'm willing to live with that until someone comes up with



part-000.sig (application/pgp-signature)