Sure—valid question.

In the case above, I would expect r.distance(pStart - 1)==1 and r.distance(pEnd - 1)==0. Having the distance method return 0 implies that the point we are comparing against is in R. The reason that I think the distance code is erroneous is that R is [1L, 6L), but 6L is not in [1L, 6L), and therefore region(0, 1L, 6L).distance(point(0, 6L) should return 1, not 0.