Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-06-28 07:26:53


From: "Kloss, Burkhard" <Burkhard.Kloss_at_[hidden]>

> <snip - lot's of good arguments>
>
> >As a programmer, I use both FORTRAN (1 based by default) and
> >C/C++ (0 based) and know I have to change over
>
> True - but it's one thing to switch indexing regimes when switching
> languages. Within a language it should be consistent.

Even within a language, sometimes a consistent indexing scheme is
counter-intuitive. Function arguments for me logically start from one, not
zero; there is no conflict because I don't use [] to access them.

Every bind/lambda library I know of uses free1/arg1/_1/whatever1 to refer to
the first argument. The standard library uses bind1st to bind the first
argument, and std::pair's first element is called 'first.'

Of course every array-like object that is accessed using operator[] uses
zero-based indexing.

The problem with tuple is that it doesn't fall in either class: if I have a
tuple t, I can use neither t[0] nor t.first to refer to its first element.

So neither "consistency with arrays" nor "consistency with bind libraries
and std::pair" is a convincing argument. Both schemes are equally valid.

--
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