Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2003-10-29 08:26:31


"Pavol Droba" <droba_at_[hidden]> wrote in message
news:20031029071346.GO5420_at_lenin.felcer.sk...
> On Wed, Oct 29, 2003 at 12:09:23AM -0000, Andy Little wrote:
> >
> > "Ross MacGregor" <ross__macgregor_at_[hidden]> wrote in message
> > news:bnmmlm$vsd$1_at_sea.gmane.org...
> > >
> > > Rob Stewart wrote:
> > >
> > > > From: David Abrahams <dave_at_[hidden]>
> > > >
> > > >>I don't get it. The first element of a sequence is s[0]. Why
> > > >>shouldn't the first matching substring be find_nth(s, XX, 0)?
> > > >
> > > > Because s[0] isn't the 0th element; it's the first. As I said,
> > > > we use ordinals to refer to things like this. Addressing an
> > > > element uses an index, and indexes start at zero. "nth"
> > > > explicitly refers to ordinals, and there's no 0th; you start with
> > > > 1st, so find_nth() should reasonably start numbering from one.
> > >
> > > Yes agree with Rob on this one. I have been using 0 based indexes for
a
> > > long long time, but when i see find_nth(), I expect 1 to be the first
> > > occurence.
> > >
> > > I think in this case naming guidlines should override convention or
> > > usage concerns. If you use a term like "nth" in the name, it should
> > > reflect its usage in the english language.
> >
> > "offset" does it for me... find_offset() ...?
>
> If just a name is confusing, I have no problem to rename it. However the
problem
> would be to find the better name. I don't like find_offset. It does not
> decsribe what it is suppose to do.

The real issue is the equation "first" == 1 or "first" == 0;
Surely there is only one 'first' that fits C/C++ here:

        for (int n = 0; n < lim ; ++n) {
            if (match(n)){
               find_nth(cont,str,n);
            }
        }

ding dong ding dong ... but hope this now makes 3 to 2 for 'first' ==
0 ... :-)

---------------------
BTW Basic is often regarded as a ""toy" language, but deserves its place in
history.
An old BBC Basic language manual from 1982
 lists LEFT$(STR_v$,n) , MID$(STR_v$,pos,n), and RIGHT$(STR_v$,n) and A$ +
B$ as operations.

------------------------
regards
Andy Little


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk