Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-06-20 07:22:07


From: "John Max Skaller" <skaller_at_[hidden]>

> Peter Dimov wrote:
> >
> > Zero-based indexing is usually more intuitive, however, when tuple is
used
> > as a building block for a bind/lambda library, the arguments are
one-based.
> >
> > FWIW, I made the same decision (one-based "tuples") in bind.hpp (in the
> > vault.)
>
> I used 1 indexing in Felix, but just changed it to 0 based.
> A tuple of elements of the same type is an array.
> The convention in mathematics is 1 origin, in C it is 0 origin.
> I personally prefer 1 origin, but I also dislike inconsistencies.

When you consider 'tuple' on its own, zero-based indexing is more
consistent; but when you make the next step to

bind(f, _1, _2);

and

_1 + _2

(replace _N with freeN according to taste :-) )

one-based indexing is much more intuitive.

Of course you could derive an one-based lambda/bind library from a
zero-based tuple library, but the potential off-by-one errors are very
difficult to hunt down. :-))

--
Peter Dimov
Multi Media Ltd.

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