Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-16 11:04:26


On Wednesday 16 January 2002 10:51 am, you wrote:
> I think FOR is better (than GENERATE or REPEAT_WHILE). After all,
> this is the preprocessor, so I think that the context makes it
> obvious not to expect FOR to necessarily be too similar to WHILE and
> to assume that it probably generates something iteratively.

My strongest argument is that C++ programmers know what a 'for' loop is, and
how it works, and the closer the preprocessor library mimics that
longstanding knowledge the easier it will be for programmers to understand
what preprocessor code is doing.

> > #define BOOST_PP_GENERATE(D,C,F,I) /* ... */
> >
> > 'D' is the initial value of the induction variable, 'C' is the
>
> condition, and
>
> > 'F' is the increment expression. 'I' is the body of the loop, but
>
> of course
>
> > it needs to be a macro parameter for things to work.
>
> By the way, in the preprocessor it mostly does not matter, but in
> functional languages that support partial application, the data being
> inspected is usually the last argument to the (higher order)
> function. The purpose of this is to make it easier to compose new
> (first order) functions.

Fair enough, but I stick to the above argument:

  for(init, condition, increment) body

is easily translatable with

  BOOST_PP_FOR(D,C,F,I)

        Doug


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