|
Boost : |
From: Rob Stewart (stewart_at_[hidden])
Date: 2003-10-29 13:34:46
From: Pavol Droba <droba_at_[hidden]>
> On Wed, Oct 29, 2003 at 10:17:55AM -0500, Rob Stewart wrote:
>
> > I couldn't disagree more. Were I reviewing that code without
> > knowing a priori that find_nth() used zero-based numbering, I'd
> > flag that as an error. The *name* find_nth() invokes ordinals
> > and there's no 0th. One poster suggested that the year before
> > one's first birthday, is the 0th year. Sorry, but I've never
> > heard anyone mention the 0th year of a child's life.
>
> There is always quite a big difference between human language
> and formal/scientific definitions.
>
> 1st year is actualy something between 0 and 0.9999... so it has
> naturaly the index 0.
Sure. The first year of life can be *indexed* with zero. I
never suggested otherwise.
> > If you change "nth" in "find_nth" to something else, or rename
> > the function altogether, we avoid the confusion.
>
> Actualy, I don't know about any native C/C++ entity which has 1-based
> indexing, so does not have to be so unnatural as it seems.
I know of no C/C++ entity with 1-based indexing either. That's
beside the point. We're talking about the nth thing in a
container, not the thing at index zero.
Matthias Schabel latched onto my point in a post today in which
he invokes the definition of "first" and correlated the first
item to index zero in "C convention." That's been my point all
along. You seem to be willing to ignore the "nth" in "find_nth"
and concentrate on the result as being a virtual collection which
is indexed by the value passed to find_nth(). I look at the
function call, find_nth(a, b, 0) as nonsensical because there
cannot be a 0th anything.
> I have updated docs with explicit note, that the index is 0-based.
This is fine, but it doesn't preclude the mistake that many will
make in associating "nth" with "starts at 1."
> To improve the naming, I can change the name of paramter from "nth" to "index".
> This way the "find_nth" function will search for an n-th occurence of the
> matching string, referenced by an "index".
>
> Would this make this matter more clear?
I already said as much, though I was suggesting "index" and not
"find_index" since prior art uses the former.
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk