
Boost : 
From: Douglas Gregor (gregod_at_[hidden])
Date: 20010527 10:12:43
On Sunday 27 May 2001 03:21 am, you wrote:
>  In boost_at_y..., Douglas Gregor <gregod_at_c...> wrote:
> > On Saturday 26 May 2001 10:58 pm, you wrote:
> > [snip]
> >
> > > PS> But what if we disallow the third level []?
> > > e[0] is a paradox even with the other iterator
> > > styles: e(0) or e.repeat(0). Should it match
> > > anything or nothing? Matching anything is
> > > the universal string U. The simplest way out
> > > thatI could think of is to disallow it.
> >
> > One would expect e(0) to match nothing because, presumable, e(1) ==
>
> e,
>
> > e(2) = e >> e, etc. That's what I would expect from the single
>
> argument forms.
>
> > This goes back to the exact problem that came up with the
>
> multidimensional
>
> > array library. The following is ambiguous:
> >
> > e[3][5]
> >
> > It could equal e[3]  e[4]  e[5] or it could equal e[15].
> > Now you know why I support using the () syntax or a repeat function
>
> instead
>
> > of operator[].
> >
> > I mentioned it back in the multidim library discussions, so I'll
>
> mention it
>
> > here. If we wanted a large degree of flexibility (as was needed for
>
> array
>
> > slicing), we could support syntax like:
> >
> > e[0 <= stride(2) <= 8]
> >
> > which is equivalent to:
> >
> > e[0]  e[2]  e[4]  e[6]  e[8]
> >
> > Doug
>
> ========================================
> Is it just me? Whuy am I not getting
> the messages from the boost mailing list?
> =========================================
Sounds like it it's just you :(
> Anyway, consider this:
>
> struct X { X1 operator[](uint n) const; };
> struct X1 { X2 operator[](uint n) const; };
> struct X2 {};
>
> Now:
>
> X x;
>
> x[1]; ... yields an X1 type
> x[1][2]; ... yields an X2 type
> x[1][2][3]; ... no such operator in X2
>
> Joel de Guzman
I know this, and I'm assuming there are two forms for repetition:
e[N]  Repeat "e" exactly N times
e[X][Y]  Repeat "e" at least X and at most Y times (Y can be infinity).
Using the bracket operator for this creates an ambiguity with, for instance:
e[X][Y]
This could be read as "repeat `e' at least X and at most Y times" or "repeat
`e' X times and then repeat that Y times." If we instead use a syntax where
there is a comma between X and Y, then we've surely differentiated between
two repetition forms (e[X][Y] is obviously different than e[X, Y]). Brackets
unfortunately won't let us do that, but the function call operator() will, as
will free functions.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk